ruby-changes:22525
From: knu <ko1@a...>
Date: Mon, 13 Feb 2012 09:25:35 +0900 (JST)
Subject: [ruby-changes:22525] knu:r34574 (ruby_1_9_3): merge revision(s) 34355:
knu 2012-02-12 16:58:16 +0900 (Sun, 12 Feb 2012) New Revision: 34574 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34574 Log: merge revision(s) 34355: * misc/rdoc-mode.el (rdoc-imenu-create-index): Add imenu support to rdoc-mode. * misc/rdoc-mode.el (rdoc-mode): Fix regexp patterns containing "\s " where CR/LF is not supposed to match. Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/misc/rdoc-mode.el branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 34573) +++ ruby_1_9_3/ChangeLog (revision 34574) @@ -1,3 +1,11 @@ +Sun Feb 12 16:57:56 2012 Akinori MUSHA <knu@i...> + + * misc/rdoc-mode.el (rdoc-imenu-create-index): Add imenu support + to rdoc-mode. + + * misc/rdoc-mode.el (rdoc-mode): Fix regexp patterns containing + "\s " where CR/LF is not supposed to match. + Sun Feb 12 16:56:23 2012 Akinori MUSHA <knu@i...> * misc/rdoc-mode.el (rdoc-mode): Add provide so that requiring Index: ruby_1_9_3/misc/rdoc-mode.el =================================================================== --- ruby_1_9_3/misc/rdoc-mode.el (revision 34573) +++ ruby_1_9_3/misc/rdoc-mode.el (revision 34574) @@ -12,7 +12,7 @@ "Major mode for RD editing. \\{rdoc-mode-map}" (make-local-variable 'paragraph-separate) - (setq paragraph-separate "^\\(=+\\|\\*+\\)\\s \\|^\\s *$") + (setq paragraph-separate "^\\(=+\\|\\*+\\)[ \t\v\f]*\\|^\\s *$") (make-local-variable 'paragraph-start) (setq paragraph-start paragraph-separate) (make-local-variable 'require-final-newline) @@ -22,7 +22,7 @@ (make-local-variable 'font-lock-keywords) (setq font-lock-keywords rdoc-font-lock-keywords) (make-local-variable 'outline-regexp) - (setq outline-regexp "^\\(=+\\)\\s ") + (setq outline-regexp "^\\(=+\\)[ \t\v\f]*") (outline-minor-mode t) (setq show-trailing-whitespace t) (rdoc-setup-keys) @@ -56,19 +56,19 @@ (defvar rdoc-font-lock-keywords (list - (list "^= .*$" + (list "^=([^=\r\n].*)?$" 0 rdoc-heading1-face) - (list "^== .*$" + (list "^==([^=\r\n].*)?$" 0 rdoc-heading2-face) - (list "^=== .*$" + (list "^===([^=\r\n].*)?$" 0 rdoc-heading3-face) - (list "^=====* .*$" + (list "^====+.*$" 0 rdoc-heading4-face) - (list "\\(^\\|\\s \\)\\(\\*\\(\\sw\\|[-_:]\\)+\\*\\)\\($\\|\\s \\)" + (list "\\(^\\|[ \t\v\f]\\)\\(\\*\\(\\sw\\|[-_:]\\)+\\*\\)\\($\\|[ \t\v\f]\\)" 2 rdoc-bold-face) ; *bold* - (list "\\(^\\|\\s \\)\\(_\\(\\sw\\|[-_:]\\)+_\\)\\($\\|\\s \\)" + (list "\\(^\\|[ \t\v\f]\\)\\(_\\(\\sw\\|[-_:]\\)+_\\)\\($\\|[ \t\v\f]\\)" 2 rdoc-emphasis-face) ; _emphasis_ - (list "\\(^\\|\\s \\)\\(\\+\\(\\sw\\|[-_:]\\)+\\+\\)\\($\\|\\s \\)" + (list "\\(^\\|[ \t\v\f]\\)\\(\\+\\(\\sw\\|[-_:]\\)+\\+\\)\\($\\|[ \t\v\f]\\)" 2 rdoc-code-face) ; +code+ (list "<em>[^<>]*</em>" 0 rdoc-emphasis-face) (list "<i>[^<>]*</i>" 0 rdoc-emphasis-face) @@ -77,9 +77,54 @@ (list "<code>[^<>]*</code>" 0 rdoc-code-face) (list "^\\([-*]\\|[0-9]+\\.\\|[A-Za-z]\\.\\)\\s " 1 rdoc-description-face) ; bullet | numbered | alphabetically numbered - (list "^\\[[^\]]*\\]\\|\\S .*::\\)\\(\\s \\|$\\)" + (list "^\\[[^\]]*\\]\\|\\S .*::\\)\\([ \t\v\f]\\|$\\)" 1 rdoc-description-face) ; labeled | node - ;(list "^\\s +\\(.*\\)" 1 rdoc-verbatim-face) + ;(list "^[ \t\v\f]+\\(.*\\)" 1 rdoc-verbatim-face) )) +(defun rdoc-imenu-create-index () + (let ((root '(nil . nil)) + cur-alist + (cur-level 0) + (pattern (concat outline-regexp "\\(.*?\\)[ \t\v\f]*$")) + (empty-heading "-") + (self-heading ".") + pos level heading alist) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward pattern (point-max) t) + (setq heading (match-string-no-properties 2) + level (min 6 (length (match-string-no-properties 1))) + pos (match-beginning 1)) + (if (= (length heading) 0) + (setq heading empty-heading)) + (setq alist (list (cons heading pos))) + (cond + ((= cur-level level) ; new sibling + (setcdr cur-alist alist) + (setq cur-alist alist)) + ((< cur-level level) ; first child + (dotimes (i (- level cur-level 1)) + (setq alist (list (cons empty-heading alist)))) + (if cur-alist + (let* ((parent (car cur-alist)) + (self-pos (cdr parent))) + (setcdr parent (cons (cons self-heading self-pos) alist))) + (setcdr root alist)) ; primogenitor + (setq cur-alist alist + cur-level level)) + (t ; new sibling of an ancestor + (let ((sibling-alist (last (cdr root)))) + (dotimes (i (1- level)) + (setq sibling-alist (last (cdar sibling-alist)))) + (setcdr sibling-alist alist) + (setq cur-alist alist + cur-level level)))))) + (cdr root))) + +(defun rdoc-set-imenu-create-index-function () + (setq imenu-create-index-function 'rdoc-imenu-create-index)) + +(add-hook 'rdoc-mode-hook 'rdoc-set-imenu-create-index-function) + (provide 'rdoc-mode) Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 34573) +++ ruby_1_9_3/version.h (revision 34574) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 102 +#define RUBY_PATCHLEVEL 103 #define RUBY_RELEASE_DATE "2012-02-12" #define RUBY_RELEASE_YEAR 2012 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/