diff options
| author | Stefan Monnier | 2002-10-02 22:04:53 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-10-02 22:04:53 +0000 |
| commit | 2f239ac598eee262aa0a03b2458f70060f91432b (patch) | |
| tree | bc69a9338caedddf5fa80f86c0285a9c7b88b9fc | |
| parent | 9715399e582f026868841a0a2b017112843cf60d (diff) | |
| download | emacs-2f239ac598eee262aa0a03b2458f70060f91432b.tar.gz emacs-2f239ac598eee262aa0a03b2458f70060f91432b.zip | |
(outline-1, outline-2, outline-3, outline-4)
(outline-5, outline-6, outline-7, outline-8): New faces.
(outline-font-lock-faces, outline-font-lock-levels): New vars.
(outline-font-lock-face): New fun.
(outline-font-lock-keywords): Use it.
(outline-font-lock-level): Remove.
(outline-mode, outline-next-preface, outline-next-heading)
(outline-previous-heading, outline-next-visible-heading):
Use shy group.
(outline-level) <var>: Update calling convention.
(outline-level) <fun>: Take advantage of it.
(outline-demote): Don't assume the match-data is still uptodate.
(outline-up-heading): Simplify and make sure the match data is
properly set at the end.
| -rw-r--r-- | lisp/ChangeLog | 39 | ||||
| -rw-r--r-- | lisp/textmodes/outline.el | 122 |
2 files changed, 103 insertions, 58 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 59fbd6b6bab..dad64927569 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,7 +1,23 @@ | |||
| 1 | 2002-10-02 Stefan Monnier <monnier@cs.yale.edu> | ||
| 2 | |||
| 3 | * textmodes/outline.el (outline-1, outline-2, outline-3, outline-4) | ||
| 4 | (outline-5, outline-6, outline-7, outline-8): New faces. | ||
| 5 | (outline-font-lock-faces, outline-font-lock-levels): New vars. | ||
| 6 | (outline-font-lock-face): New fun. | ||
| 7 | (outline-font-lock-keywords): Use it. | ||
| 8 | (outline-font-lock-level): Remove. | ||
| 9 | (outline-mode, outline-next-preface, outline-next-heading) | ||
| 10 | (outline-previous-heading, outline-next-visible-heading): | ||
| 11 | Use shy group. | ||
| 12 | (outline-level) <var>: Update calling convention. | ||
| 13 | (outline-level) <fun>: Take advantage of it. | ||
| 14 | (outline-demote): Don't assume the match-data is still uptodate. | ||
| 15 | (outline-up-heading): Simplify and make sure the match data is | ||
| 16 | properly set at the end. | ||
| 17 | |||
| 1 | 2002-10-02 Markus Rost <rost@math.ohio-state.edu> | 18 | 2002-10-02 Markus Rost <rost@math.ohio-state.edu> |
| 2 | 19 | ||
| 3 | * progmodes/sh-script.el (sh-alias-alist): Use append instead of | 20 | * progmodes/sh-script.el (sh-alias-alist): Use append instead of nconc. |
| 4 | nconc. | ||
| 5 | 21 | ||
| 6 | * startup.el (normal-top-level): Reset standard-value property of | 22 | * startup.el (normal-top-level): Reset standard-value property of |
| 7 | `user-full-name' here. | 23 | `user-full-name' here. |
| @@ -15,17 +31,24 @@ | |||
| 15 | toolbar/page-down.pbm, toolbar/page-down.xpm, toolbar/refile.pbm, | 31 | toolbar/page-down.pbm, toolbar/page-down.xpm, toolbar/refile.pbm, |
| 16 | toolbar/refile.xpm, toolbar/repack.pbm, toolbar/repack.xpm, | 32 | toolbar/refile.xpm, toolbar/repack.pbm, toolbar/repack.xpm, |
| 17 | toolbar/rescan.pbm, toolbar/rescan.xpm, toolbar/show.pbm, | 33 | toolbar/rescan.pbm, toolbar/rescan.xpm, toolbar/show.pbm, |
| 18 | toolbar/show.xpm, toolbar/widen.pbm, toolbar/widen.xpm: Upgraded | 34 | toolbar/show.xpm, toolbar/widen.pbm, toolbar/widen.xpm: |
| 19 | to mh-e version 6.1.1. Full ChangeLog available in | 35 | Upgraded to mh-e version 6.1.1. Full ChangeLog available in |
| 20 | http://prdownloads.sourceforge.net/mh-e/mh-e-6.1.tgz?download . | 36 | http://prdownloads.sourceforge.net/mh-e/mh-e-6.1.tgz?download . |
| 21 | There were no user-visible changes in 6.1.1 from 6.1--only the | 37 | There were no user-visible changes in 6.1.1 from 6.1--only the |
| 22 | section of the Makefile that installs the files into Emacs was | 38 | section of the Makefile that installs the files into Emacs was changed. |
| 23 | changed. | 39 | |
| 40 | 2002-10-01 Stefan Monnier <monnier@cs.yale.edu> | ||
| 41 | |||
| 42 | * pcvs.el (cvs-mode-find-file): Look up font-lock-face so it also | ||
| 43 | works when font-lock is turned off. | ||
| 44 | |||
| 45 | * jit-lock.el (jit-lock-fontify-now): Don't widen. | ||
| 46 | Let the jit-lock-functions do it if they want to. | ||
| 24 | 47 | ||
| 25 | 2002-10-01 Juanma Barranquero <lektu@terra.es> | 48 | 2002-10-01 Juanma Barranquero <lektu@terra.es> |
| 26 | 49 | ||
| 27 | * eshell/esh-module.el (eshell-load-defgroups): Add "no-byte-compile: t" | 50 | * eshell/esh-module.el (eshell-load-defgroups): |
| 28 | to subdirs.el. | 51 | Add "no-byte-compile: t" to subdirs.el. |
| 29 | 52 | ||
| 30 | * makefile.w32-in (update-subdirs-CMD): Likewise. | 53 | * makefile.w32-in (update-subdirs-CMD): Likewise. |
| 31 | 54 | ||
diff --git a/lisp/textmodes/outline.el b/lisp/textmodes/outline.el index d7618ea2aaf..4346c0eddf2 100644 --- a/lisp/textmodes/outline.el +++ b/lisp/textmodes/outline.el | |||
| @@ -150,30 +150,52 @@ in the file it applies to." | |||
| 150 | (defvar outline-font-lock-keywords | 150 | (defvar outline-font-lock-keywords |
| 151 | '(;; | 151 | '(;; |
| 152 | ;; Highlight headings according to the level. | 152 | ;; Highlight headings according to the level. |
| 153 | (eval . (list (concat "^" outline-regexp ".+") | 153 | (eval . (list (concat "^\\(?:" outline-regexp "\\).+") |
| 154 | 0 '(or (cdr (assq (outline-font-lock-level) | 154 | 0 '(outline-font-lock-face) nil t))) |
| 155 | ;; FIXME: this is silly! | ||
| 156 | '((1 . font-lock-function-name-face) | ||
| 157 | (2 . font-lock-variable-name-face) | ||
| 158 | (3 . font-lock-keyword-face) | ||
| 159 | (4 . font-lock-builtin-face) | ||
| 160 | (5 . font-lock-comment-face) | ||
| 161 | (6 . font-lock-constant-face) | ||
| 162 | (7 . font-lock-type-face) | ||
| 163 | (8 . font-lock-string-face)))) | ||
| 164 | font-lock-warning-face) | ||
| 165 | nil t))) | ||
| 166 | "Additional expressions to highlight in Outline mode.") | 155 | "Additional expressions to highlight in Outline mode.") |
| 167 | 156 | ||
| 168 | (defun outline-font-lock-level () | 157 | (defface outline-1 '((t :inherit font-lock-function-name-face)) "Level 1.") |
| 169 | (let ((count 1)) | 158 | (defface outline-2 '((t :inherit font-lock-variable-name-face)) "Level 2.") |
| 170 | (save-excursion | 159 | (defface outline-3 '((t :inherit font-lock-keyword-face)) "Level 3.") |
| 171 | (outline-back-to-heading t) | 160 | (defface outline-4 '((t :inherit font-lock-builtin-face)) "Level 4.") |
| 172 | (while (and (not (bobp)) | 161 | (defface outline-5 '((t :inherit font-lock-comment-face)) "Level 5.") |
| 173 | (not (eq (funcall outline-level) 1))) | 162 | (defface outline-6 '((t :inherit font-lock-constant-face)) "Level 6.") |
| 174 | (outline-up-heading 1 t) | 163 | (defface outline-7 '((t :inherit font-lock-type-face)) "Level 7.") |
| 175 | (setq count (1+ count))) | 164 | (defface outline-8 '((t :inherit font-lock-string-face)) "Level 8.") |
| 176 | count))) | 165 | |
| 166 | (defvar outline-font-lock-faces | ||
| 167 | [outline-1 outline-2 outline-3 outline-4 | ||
| 168 | outline-5 outline-6 outline-7 outline-8]) | ||
| 169 | |||
| 170 | (defvar outline-font-lock-levels nil) | ||
| 171 | (make-variable-buffer-local 'outline-font-lock-levels) | ||
| 172 | |||
| 173 | (defun outline-font-lock-face () | ||
| 174 | ;; (save-excursion | ||
| 175 | ;; (outline-back-to-heading t) | ||
| 176 | ;; (let* ((count 0) | ||
| 177 | ;; (start-level (funcall outline-level)) | ||
| 178 | ;; (level start-level) | ||
| 179 | ;; face-level) | ||
| 180 | ;; (while (not (setq face-level | ||
| 181 | ;; (if (or (bobp) (eq level 1)) 0 | ||
| 182 | ;; (cdr (assq level outline-font-lock-levels))))) | ||
| 183 | ;; (outline-up-heading 1 t) | ||
| 184 | ;; (setq count (1+ count)) | ||
| 185 | ;; (setq level (funcall outline-level))) | ||
| 186 | ;; ;; Remember for later. | ||
| 187 | ;; (unless (zerop count) | ||
| 188 | ;; (setq face-level (+ face-level count)) | ||
| 189 | ;; (push (cons start-level face-level) outline-font-lock-levels)) | ||
| 190 | ;; (condition-case nil | ||
| 191 | ;; (aref outline-font-lock-faces face-level) | ||
| 192 | ;; (error font-lock-warning-face)))) | ||
| 193 | (save-excursion | ||
| 194 | (goto-char (match-beginning 0)) | ||
| 195 | (looking-at outline-regexp) | ||
| 196 | (condition-case nil | ||
| 197 | (aref outline-font-lock-faces (1- (funcall outline-level))) | ||
| 198 | (error font-lock-warning-face)))) | ||
| 177 | 199 | ||
| 178 | (defvar outline-view-change-hook nil | 200 | (defvar outline-view-change-hook nil |
| 179 | "Normal hook to be run after outline visibility changes.") | 201 | "Normal hook to be run after outline visibility changes.") |
| @@ -223,11 +245,11 @@ Turning on outline mode calls the value of `text-mode-hook' and then of | |||
| 223 | ;; Cause use of ellipses for invisible text. | 245 | ;; Cause use of ellipses for invisible text. |
| 224 | (add-to-invisibility-spec '(outline . t)) | 246 | (add-to-invisibility-spec '(outline . t)) |
| 225 | (set (make-local-variable 'paragraph-start) | 247 | (set (make-local-variable 'paragraph-start) |
| 226 | (concat paragraph-start "\\|\\(" outline-regexp "\\)")) | 248 | (concat paragraph-start "\\|\\(?:" outline-regexp "\\)")) |
| 227 | ;; Inhibit auto-filling of header lines. | 249 | ;; Inhibit auto-filling of header lines. |
| 228 | (set (make-local-variable 'auto-fill-inhibit-regexp) outline-regexp) | 250 | (set (make-local-variable 'auto-fill-inhibit-regexp) outline-regexp) |
| 229 | (set (make-local-variable 'paragraph-separate) | 251 | (set (make-local-variable 'paragraph-separate) |
| 230 | (concat paragraph-separate "\\|\\(" outline-regexp "\\)")) | 252 | (concat paragraph-separate "\\|\\(?:" outline-regexp "\\)")) |
| 231 | (set (make-local-variable 'font-lock-defaults) | 253 | (set (make-local-variable 'font-lock-defaults) |
| 232 | '(outline-font-lock-keywords t nil nil backward-paragraph)) | 254 | '(outline-font-lock-keywords t nil nil backward-paragraph)) |
| 233 | (setq imenu-generic-expression | 255 | (setq imenu-generic-expression |
| @@ -265,7 +287,8 @@ See the command `outline-mode' for more information on this mode." | |||
| 265 | 287 | ||
| 266 | (defcustom outline-level 'outline-level | 288 | (defcustom outline-level 'outline-level |
| 267 | "*Function of no args to compute a header's nesting level in an outline. | 289 | "*Function of no args to compute a header's nesting level in an outline. |
| 268 | It can assume point is at the beginning of a header line." | 290 | It can assume point is at the beginning of a header line and that the match |
| 291 | data reflects the `outline-regexp'." | ||
| 269 | :type 'function | 292 | :type 'function |
| 270 | :group 'outlines) | 293 | :group 'outlines) |
| 271 | 294 | ||
| @@ -286,18 +309,14 @@ a given level and to find the level of a given heading.") | |||
| 286 | Point must be at the beginning of a header line. | 309 | Point must be at the beginning of a header line. |
| 287 | This is actually either the level specified in `outline-heading-alist' | 310 | This is actually either the level specified in `outline-heading-alist' |
| 288 | or else the number of characters matched by `outline-regexp'." | 311 | or else the number of characters matched by `outline-regexp'." |
| 289 | (save-excursion | 312 | (or (cdr (assoc (match-string 0) outline-heading-alist)) |
| 290 | (if (not (looking-at outline-regexp)) | 313 | (- (match-end 0) (match-beginning 0)))) |
| 291 | ;; This should never happen | ||
| 292 | 1000 | ||
| 293 | (or (cdr (assoc (match-string 0) outline-heading-alist)) | ||
| 294 | (- (match-end 0) (match-beginning 0)))))) | ||
| 295 | 314 | ||
| 296 | (defun outline-next-preface () | 315 | (defun outline-next-preface () |
| 297 | "Skip forward to just before the next heading line. | 316 | "Skip forward to just before the next heading line. |
| 298 | If there's no following heading line, stop before the newline | 317 | If there's no following heading line, stop before the newline |
| 299 | at the end of the buffer." | 318 | at the end of the buffer." |
| 300 | (if (re-search-forward (concat "\n\\(" outline-regexp "\\)") | 319 | (if (re-search-forward (concat "\n\\(?:" outline-regexp "\\)") |
| 301 | nil 'move) | 320 | nil 'move) |
| 302 | (goto-char (match-beginning 0))) | 321 | (goto-char (match-beginning 0))) |
| 303 | (if (and (bolp) (not (bobp))) | 322 | (if (and (bolp) (not (bobp))) |
| @@ -306,14 +325,14 @@ at the end of the buffer." | |||
| 306 | (defun outline-next-heading () | 325 | (defun outline-next-heading () |
| 307 | "Move to the next (possibly invisible) heading line." | 326 | "Move to the next (possibly invisible) heading line." |
| 308 | (interactive) | 327 | (interactive) |
| 309 | (if (re-search-forward (concat "\n\\(" outline-regexp "\\)") | 328 | (if (re-search-forward (concat "\n\\(?:" outline-regexp "\\)") |
| 310 | nil 'move) | 329 | nil 'move) |
| 311 | (goto-char (1+ (match-beginning 0))))) | 330 | (goto-char (1+ (match-beginning 0))))) |
| 312 | 331 | ||
| 313 | (defun outline-previous-heading () | 332 | (defun outline-previous-heading () |
| 314 | "Move to the previous (possibly invisible) heading line." | 333 | "Move to the previous (possibly invisible) heading line." |
| 315 | (interactive) | 334 | (interactive) |
| 316 | (re-search-backward (concat "^\\(" outline-regexp "\\)") | 335 | (re-search-backward (concat "^\\(?:" outline-regexp "\\)") |
| 317 | nil 'move)) | 336 | nil 'move)) |
| 318 | 337 | ||
| 319 | (defsubst outline-invisible-p () | 338 | (defsubst outline-invisible-p () |
| @@ -331,7 +350,7 @@ Only visible heading lines are considered, unless INVISIBLE-OK is non-nil." | |||
| 331 | (let (found) | 350 | (let (found) |
| 332 | (save-excursion | 351 | (save-excursion |
| 333 | (while (not found) | 352 | (while (not found) |
| 334 | (or (re-search-backward (concat "^\\(" outline-regexp "\\)") | 353 | (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)") |
| 335 | nil t) | 354 | nil t) |
| 336 | (error "before first heading")) | 355 | (error "before first heading")) |
| 337 | (setq found (and (or invisible-ok (not (outline-invisible-p))) | 356 | (setq found (and (or invisible-ok (not (outline-invisible-p))) |
| @@ -408,7 +427,9 @@ If prefix argument CHILDREN is given, demote also all the children." | |||
| 408 | (progn | 427 | (progn |
| 409 | (outline-next-heading) | 428 | (outline-next-heading) |
| 410 | (<= (funcall outline-level) level))))) | 429 | (<= (funcall outline-level) level))))) |
| 411 | (unless (eobp) (match-string 0)))) | 430 | (unless (eobp) |
| 431 | (looking-at outline-regexp) | ||
| 432 | (match-string 0)))) | ||
| 412 | (save-match-data | 433 | (save-match-data |
| 413 | ;; Bummer!! There is no lower heading in the buffer. | 434 | ;; Bummer!! There is no lower heading in the buffer. |
| 414 | ;; Let's try to invent one by repeating the first char. | 435 | ;; Let's try to invent one by repeating the first char. |
| @@ -450,13 +471,13 @@ A heading line is one that starts with a `*' (or that | |||
| 450 | (end-of-line)) | 471 | (end-of-line)) |
| 451 | (while (and (not (bobp)) (< arg 0)) | 472 | (while (and (not (bobp)) (< arg 0)) |
| 452 | (while (and (not (bobp)) | 473 | (while (and (not (bobp)) |
| 453 | (re-search-backward (concat "^\\(" outline-regexp "\\)") | 474 | (re-search-backward (concat "^\\(?:" outline-regexp "\\)") |
| 454 | nil 'move) | 475 | nil 'move) |
| 455 | (outline-invisible-p))) | 476 | (outline-invisible-p))) |
| 456 | (setq arg (1+ arg))) | 477 | (setq arg (1+ arg))) |
| 457 | (while (and (not (eobp)) (> arg 0)) | 478 | (while (and (not (eobp)) (> arg 0)) |
| 458 | (while (and (not (eobp)) | 479 | (while (and (not (eobp)) |
| 459 | (re-search-forward (concat "^\\(" outline-regexp "\\)") | 480 | (re-search-forward (concat "^\\(?:" outline-regexp "\\)") |
| 460 | nil 'move) | 481 | nil 'move) |
| 461 | (outline-invisible-p))) | 482 | (outline-invisible-p))) |
| 462 | (setq arg (1- arg))) | 483 | (setq arg (1- arg))) |
| @@ -736,18 +757,19 @@ With argument, move up ARG levels. | |||
| 736 | If INVISIBLE-OK is non-nil, also consider invisible lines." | 757 | If INVISIBLE-OK is non-nil, also consider invisible lines." |
| 737 | (interactive "p") | 758 | (interactive "p") |
| 738 | (outline-back-to-heading invisible-ok) | 759 | (outline-back-to-heading invisible-ok) |
| 739 | (if (eq (funcall outline-level) 1) | 760 | (let ((start-level (funcall outline-level))) |
| 740 | (error "Already at top level of the outline")) | 761 | (if (eq start-level 1) |
| 741 | (while (and (> (funcall outline-level) 1) | 762 | (error "Already at top level of the outline")) |
| 742 | (> arg 0) | 763 | (while (and (> start-level 1) (> arg 0) (not (bobp))) |
| 743 | (not (bobp))) | 764 | (let ((level start-level)) |
| 744 | (let ((present-level (funcall outline-level))) | 765 | (while (not (or (< level start-level) (bobp))) |
| 745 | (while (and (not (< (funcall outline-level) present-level)) | 766 | (if invisible-ok |
| 746 | (not (bobp))) | 767 | (outline-previous-heading) |
| 747 | (if invisible-ok | 768 | (outline-previous-visible-heading 1)) |
| 748 | (outline-previous-heading) | 769 | (setq level (funcall outline-level))) |
| 749 | (outline-previous-visible-heading 1))) | 770 | (setq start-level level)) |
| 750 | (setq arg (- arg 1))))) | 771 | (setq arg (- arg 1)))) |
| 772 | (looking-at outline-regexp)) | ||
| 751 | 773 | ||
| 752 | (defun outline-forward-same-level (arg) | 774 | (defun outline-forward-same-level (arg) |
| 753 | "Move forward to the ARG'th subheading at same level as this one. | 775 | "Move forward to the ARG'th subheading at same level as this one. |