diff options
| author | Chong Yidong | 2012-12-01 13:09:12 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-12-01 13:09:12 +0800 |
| commit | 9dffb5b69353cd041027b334a9c5aadf4163ec2d (patch) | |
| tree | 36e5d76ed7301e1c5e757ecac62682e8619239e8 | |
| parent | ba03d0d932888f687ae9c9fb12e20908c6b0620f (diff) | |
| download | emacs-9dffb5b69353cd041027b334a9c5aadf4163ec2d.tar.gz emacs-9dffb5b69353cd041027b334a9c5aadf4163ec2d.zip | |
Fix last change.
* emacs-lisp/lisp-mode.el (lisp-current-defun-name):
* progmodes/m4-mode.el (m4-current-defun-name):
* progmodes/perl-mode.el (perl-current-defun-name):
* textmodes/tex-mode.el (tex-current-defun-name):
* textmodes/texinfo.el (texinfo-current-defun-name): Use save-excursion.
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 45 | ||||
| -rw-r--r-- | lisp/progmodes/cperl-mode.el | 5 | ||||
| -rw-r--r-- | lisp/progmodes/m4-mode.el | 7 | ||||
| -rw-r--r-- | lisp/progmodes/perl-mode.el | 6 | ||||
| -rw-r--r-- | lisp/textmodes/tex-mode.el | 15 | ||||
| -rw-r--r-- | lisp/textmodes/texinfo.el | 5 |
6 files changed, 45 insertions, 38 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 11dd6dc6ee2..c0380c60e11 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -240,28 +240,29 @@ font-lock keywords will not be case sensitive." | |||
| 240 | 240 | ||
| 241 | (defun lisp-current-defun-name () | 241 | (defun lisp-current-defun-name () |
| 242 | "Return the name of the defun at point, or nil." | 242 | "Return the name of the defun at point, or nil." |
| 243 | (let ((location (point))) | 243 | (save-excursion |
| 244 | ;; If we are now precisely at the beginning of a defun, make sure | 244 | (let ((location (point))) |
| 245 | ;; beginning-of-defun finds that one rather than the previous one. | 245 | ;; If we are now precisely at the beginning of a defun, make sure |
| 246 | (or (eobp) (forward-char 1)) | 246 | ;; beginning-of-defun finds that one rather than the previous one. |
| 247 | (beginning-of-defun) | 247 | (or (eobp) (forward-char 1)) |
| 248 | ;; Make sure we are really inside the defun found, not after it. | 248 | (beginning-of-defun) |
| 249 | (when (and (looking-at "\\s(") | 249 | ;; Make sure we are really inside the defun found, not after it. |
| 250 | (progn (end-of-defun) | 250 | (when (and (looking-at "\\s(") |
| 251 | (< location (point))) | 251 | (progn (end-of-defun) |
| 252 | (progn (forward-sexp -1) | 252 | (< location (point))) |
| 253 | (>= location (point)))) | 253 | (progn (forward-sexp -1) |
| 254 | (if (looking-at "\\s(") | 254 | (>= location (point)))) |
| 255 | (forward-char 1)) | 255 | (if (looking-at "\\s(") |
| 256 | ;; Skip the defining construct name, typically "defun" or | 256 | (forward-char 1)) |
| 257 | ;; "defvar". | 257 | ;; Skip the defining construct name, typically "defun" or |
| 258 | (forward-sexp 1) | 258 | ;; "defvar". |
| 259 | ;; The second element is usually a symbol being defined. If it | 259 | (forward-sexp 1) |
| 260 | ;; is not, use the first symbol in it. | 260 | ;; The second element is usually a symbol being defined. If it |
| 261 | (skip-chars-forward " \t\n'(") | 261 | ;; is not, use the first symbol in it. |
| 262 | (buffer-substring-no-properties (point) | 262 | (skip-chars-forward " \t\n'(") |
| 263 | (progn (forward-sexp 1) | 263 | (buffer-substring-no-properties (point) |
| 264 | (point)))))) | 264 | (progn (forward-sexp 1) |
| 265 | (point))))))) | ||
| 265 | 266 | ||
| 266 | (defvar lisp-mode-shared-map | 267 | (defvar lisp-mode-shared-map |
| 267 | (let ((map (make-sparse-keymap))) | 268 | (let ((map (make-sparse-keymap))) |
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 5b5097803c3..0a952cf3870 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el | |||
| @@ -1745,8 +1745,9 @@ or as help on variables `cperl-tips', `cperl-problems', | |||
| 1745 | (make-local-variable 'add-log-current-defun-function) | 1745 | (make-local-variable 'add-log-current-defun-function) |
| 1746 | (setq add-log-current-defun-function | 1746 | (setq add-log-current-defun-function |
| 1747 | (lambda () | 1747 | (lambda () |
| 1748 | (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t) | 1748 | (save-excursion |
| 1749 | (match-string-no-properties 1)))) | 1749 | (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t) |
| 1750 | (match-string-no-properties 1))))) | ||
| 1750 | 1751 | ||
| 1751 | (make-local-variable 'paragraph-start) | 1752 | (make-local-variable 'paragraph-start) |
| 1752 | (setq paragraph-start (concat "^$\\|" page-delimiter)) | 1753 | (setq paragraph-start (concat "^$\\|" page-delimiter)) |
diff --git a/lisp/progmodes/m4-mode.el b/lisp/progmodes/m4-mode.el index 9cf98d979f6..7904033e68e 100644 --- a/lisp/progmodes/m4-mode.el +++ b/lisp/progmodes/m4-mode.el | |||
| @@ -143,9 +143,10 @@ | |||
| 143 | 143 | ||
| 144 | (defun m4-current-defun-name () | 144 | (defun m4-current-defun-name () |
| 145 | "Return the name of the M4 function at point, or nil." | 145 | "Return the name of the M4 function at point, or nil." |
| 146 | (if (re-search-backward | 146 | (save-excursion |
| 147 | "^\\(\\(m4_\\)?define\\|A._DEFUN\\)(\\[?\\([A-Za-z0-9_]+\\)" nil t) | 147 | (if (re-search-backward |
| 148 | (match-string-no-properties 3))) | 148 | "^\\(\\(m4_\\)?define\\|A._DEFUN\\)(\\[?\\([A-Za-z0-9_]+\\)" nil t) |
| 149 | (match-string-no-properties 3)))) | ||
| 149 | 150 | ||
| 150 | ;;;###autoload | 151 | ;;;###autoload |
| 151 | (define-derived-mode m4-mode prog-mode "m4" | 152 | (define-derived-mode m4-mode prog-mode "m4" |
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 82f742de274..46940457d36 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el | |||
| @@ -581,8 +581,10 @@ create a new comment." | |||
| 581 | 581 | ||
| 582 | (defun perl-current-defun-name () | 582 | (defun perl-current-defun-name () |
| 583 | "The `add-log-current-defun' function in Perl mode." | 583 | "The `add-log-current-defun' function in Perl mode." |
| 584 | (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t) | 584 | (save-excursion |
| 585 | (match-string-no-properties 1))) | 585 | (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t) |
| 586 | (match-string-no-properties 1)))) | ||
| 587 | |||
| 586 | 588 | ||
| 587 | (defvar perl-mode-hook nil | 589 | (defvar perl-mode-hook nil |
| 588 | "Normal hook to run when entering Perl mode.") | 590 | "Normal hook to run when entering Perl mode.") |
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 966fa60e6de..16689b1ad02 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el | |||
| @@ -424,13 +424,14 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 424 | 424 | ||
| 425 | (defun tex-current-defun-name () | 425 | (defun tex-current-defun-name () |
| 426 | "Return the name of the TeX section/paragraph/chapter at point, or nil." | 426 | "Return the name of the TeX section/paragraph/chapter at point, or nil." |
| 427 | (when (re-search-backward | 427 | (save-excursion |
| 428 | "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" | 428 | (when (re-search-backward |
| 429 | nil t) | 429 | "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" |
| 430 | (goto-char (match-beginning 0)) | 430 | nil t) |
| 431 | (buffer-substring-no-properties | 431 | (goto-char (match-beginning 0)) |
| 432 | (1+ (point)) ; without initial backslash | 432 | (buffer-substring-no-properties |
| 433 | (line-end-position)))) | 433 | (1+ (point)) ; without initial backslash |
| 434 | (line-end-position))))) | ||
| 434 | 435 | ||
| 435 | ;;;; | 436 | ;;;; |
| 436 | ;;;; Font-Lock support | 437 | ;;;; Font-Lock support |
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index 0e45b603c1a..253b56f09b1 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el | |||
| @@ -513,8 +513,9 @@ Subexpression 1 is what goes into the corresponding `@end' statement.") | |||
| 513 | 513 | ||
| 514 | (defun texinfo-current-defun-name () | 514 | (defun texinfo-current-defun-name () |
| 515 | "Return the name of the Texinfo node at point, or nil." | 515 | "Return the name of the Texinfo node at point, or nil." |
| 516 | (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t) | 516 | (save-excursion |
| 517 | (match-string-no-properties 1))) | 517 | (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t) |
| 518 | (match-string-no-properties 1)))) | ||
| 518 | 519 | ||
| 519 | ;;; Texinfo mode | 520 | ;;; Texinfo mode |
| 520 | 521 | ||