diff options
| author | Thien-Thi Nguyen | 2004-12-23 18:22:05 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2004-12-23 18:22:05 +0000 |
| commit | aa7d6700031329370636abbef742b86bf31fc956 (patch) | |
| tree | 4134ae84e40222479cd13c3639f1121886817f19 | |
| parent | 66354420ae890d5581395f62d66b3decb007786e (diff) | |
| download | emacs-aa7d6700031329370636abbef742b86bf31fc956.tar.gz emacs-aa7d6700031329370636abbef742b86bf31fc956.zip | |
(hs-inside-comment-p): Fix omission bug:
When extending backwards, move outside the current comment first.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/hideshow.el | 29 |
2 files changed, 21 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2795cbf26d4..dea5cf3fd7b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2004-12-23 Thien-Thi Nguyen <ttn@gnu.org> | ||
| 2 | |||
| 3 | * progmodes/hideshow.el (hs-inside-comment-p): Fix omission bug: | ||
| 4 | When extending backwards, move outside the current comment first. | ||
| 5 | |||
| 1 | 2004-12-22 Kenichi Handa <handa@m17n.org> | 6 | 2004-12-22 Kenichi Handa <handa@m17n.org> |
| 2 | 7 | ||
| 3 | * international/quail.el (quail-start-translation): Fix prompt | 8 | * international/quail.el (quail-start-translation): Fix prompt |
| @@ -23,7 +28,7 @@ | |||
| 23 | (undo-outer-limit-function): Use undo-outer-limit-truncate. | 28 | (undo-outer-limit-function): Use undo-outer-limit-truncate. |
| 24 | 29 | ||
| 25 | 2004-12-21 Eli Barzilay <eli@barzilay.org> | 30 | 2004-12-21 Eli Barzilay <eli@barzilay.org> |
| 26 | 31 | ||
| 27 | * calculator.el: (calculator-radix-grouping-mode) | 32 | * calculator.el: (calculator-radix-grouping-mode) |
| 28 | (calculator-radix-grouping-digits) | 33 | (calculator-radix-grouping-digits) |
| 29 | (calculator-radix-grouping-separator): | 34 | (calculator-radix-grouping-separator): |
diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index 7013c3856e3..2c2797f97f0 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Thien-Thi Nguyen <ttn@gnu.org> | 5 | ;; Author: Thien-Thi Nguyen <ttn@gnu.org> |
| 6 | ;; Dan Nicolaescu <dann@ics.uci.edu> | 6 | ;; Dan Nicolaescu <dann@ics.uci.edu> |
| 7 | ;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines | 7 | ;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines |
| 8 | ;; Maintainer-Version: 5.31 | 8 | ;; Maintainer-Version: n/a (presently) |
| 9 | ;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning | 9 | ;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning |
| 10 | 10 | ||
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| @@ -58,7 +58,7 @@ | |||
| 58 | ;; | 58 | ;; |
| 59 | ;; (load-library "hideshow") | 59 | ;; (load-library "hideshow") |
| 60 | ;; (add-hook 'X-mode-hook ; other modes similarly | 60 | ;; (add-hook 'X-mode-hook ; other modes similarly |
| 61 | ;; '(lambda () (hs-minor-mode 1))) | 61 | ;; (lambda () (hs-minor-mode 1))) |
| 62 | ;; | 62 | ;; |
| 63 | ;; where X = {emacs-lisp,c,c++,perl,...}. You can also manually toggle | 63 | ;; where X = {emacs-lisp,c,c++,perl,...}. You can also manually toggle |
| 64 | ;; hideshow minor mode by typing `M-x hs-minor-mode'. After hideshow is | 64 | ;; hideshow minor mode by typing `M-x hs-minor-mode'. After hideshow is |
| @@ -133,10 +133,7 @@ | |||
| 133 | ;; variable `hs-special-modes-alist'. Packages that use hideshow should | 133 | ;; variable `hs-special-modes-alist'. Packages that use hideshow should |
| 134 | ;; do something like: | 134 | ;; do something like: |
| 135 | ;; | 135 | ;; |
| 136 | ;; (let ((my-mode-hs-info '(my-mode "{{" "}}" ...))) | 136 | ;; (add-to-list 'hs-special-modes-alist '(my-mode "{{" "}}" ...)) |
| 137 | ;; (if (not (member my-mode-hs-info hs-special-modes-alist)) | ||
| 138 | ;; (setq hs-special-modes-alist | ||
| 139 | ;; (cons my-mode-hs-info hs-special-modes-alist)))) | ||
| 140 | ;; | 137 | ;; |
| 141 | ;; If you have an entry that works particularly well, consider | 138 | ;; If you have an entry that works particularly well, consider |
| 142 | ;; submitting it for inclusion in hideshow.el. See docstring for | 139 | ;; submitting it for inclusion in hideshow.el. See docstring for |
| @@ -180,9 +177,9 @@ | |||
| 180 | ;; In the case of `vc-diff', here is a less invasive workaround: | 177 | ;; In the case of `vc-diff', here is a less invasive workaround: |
| 181 | ;; | 178 | ;; |
| 182 | ;; (add-hook 'vc-before-checkin-hook | 179 | ;; (add-hook 'vc-before-checkin-hook |
| 183 | ;; '(lambda () | 180 | ;; (lambda () |
| 184 | ;; (goto-char (point-min)) | 181 | ;; (goto-char (point-min)) |
| 185 | ;; (hs-show-block))) | 182 | ;; (hs-show-block))) |
| 186 | ;; | 183 | ;; |
| 187 | ;; Unfortunately, these workarounds do not restore hideshow state. | 184 | ;; Unfortunately, these workarounds do not restore hideshow state. |
| 188 | ;; If someone figures out a better way, please let me know. | 185 | ;; If someone figures out a better way, please let me know. |
| @@ -265,8 +262,7 @@ This has effect iff `search-invisible' is set to `open'." | |||
| 265 | '((c-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning) | 262 | '((c-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning) |
| 266 | (c++-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning) | 263 | (c++-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning) |
| 267 | (bibtex-mode ("^@\\S(*\\(\\s(\\)" 1)) | 264 | (bibtex-mode ("^@\\S(*\\(\\s(\\)" 1)) |
| 268 | (java-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning) | 265 | (java-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning)) |
| 269 | ) | ||
| 270 | "*Alist for initializing the hideshow variables for different modes. | 266 | "*Alist for initializing the hideshow variables for different modes. |
| 271 | Each element has the form | 267 | Each element has the form |
| 272 | (MODE START END COMMENT-START FORWARD-SEXP-FUNC ADJUST-BEG-FUNC). | 268 | (MODE START END COMMENT-START FORWARD-SEXP-FUNC ADJUST-BEG-FUNC). |
| @@ -543,10 +539,15 @@ as cdr." | |||
| 543 | (let ((q (point))) | 539 | (let ((q (point))) |
| 544 | (when (or (looking-at hs-c-start-regexp) | 540 | (when (or (looking-at hs-c-start-regexp) |
| 545 | (re-search-backward hs-c-start-regexp (point-min) t)) | 541 | (re-search-backward hs-c-start-regexp (point-min) t)) |
| 542 | ;; first get to the beginning of this comment... | ||
| 543 | (while (and (not (bobp)) | ||
| 544 | (= (point) (progn (forward-comment -1) (point)))) | ||
| 545 | (forward-char -1)) | ||
| 546 | ;; ...then extend backwards | ||
| 546 | (forward-comment (- (buffer-size))) | 547 | (forward-comment (- (buffer-size))) |
| 547 | (skip-chars-forward " \t\n\f") | 548 | (skip-chars-forward " \t\n\f") |
| 548 | (let ((p (point)) | 549 | (let ((p (point)) |
| 549 | (not-hidable nil)) | 550 | (hidable t)) |
| 550 | (beginning-of-line) | 551 | (beginning-of-line) |
| 551 | (unless (looking-at (concat "[ \t]*" hs-c-start-regexp)) | 552 | (unless (looking-at (concat "[ \t]*" hs-c-start-regexp)) |
| 552 | ;; we are in this situation: (example) | 553 | ;; we are in this situation: (example) |
| @@ -571,13 +572,13 @@ as cdr." | |||
| 571 | (when (or (not (looking-at hs-c-start-regexp)) | 572 | (when (or (not (looking-at hs-c-start-regexp)) |
| 572 | (> (point) q)) | 573 | (> (point) q)) |
| 573 | ;; we cannot hide this comment block | 574 | ;; we cannot hide this comment block |
| 574 | (setq not-hidable t))) | 575 | (setq hidable nil))) |
| 575 | ;; goto the end of the comment | 576 | ;; goto the end of the comment |
| 576 | (forward-comment (buffer-size)) | 577 | (forward-comment (buffer-size)) |
| 577 | (skip-chars-backward " \t\n\f") | 578 | (skip-chars-backward " \t\n\f") |
| 578 | (end-of-line) | 579 | (end-of-line) |
| 579 | (when (>= (point) q) | 580 | (when (>= (point) q) |
| 580 | (list (if not-hidable nil p) (point)))))))) | 581 | (list (and hidable p) (point)))))))) |
| 581 | 582 | ||
| 582 | (defun hs-grok-mode-type () | 583 | (defun hs-grok-mode-type () |
| 583 | "Set up hideshow variables for new buffers. | 584 | "Set up hideshow variables for new buffers. |