]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix last change.
authorChong Yidong <cyd@gnu.org>
Sat, 1 Dec 2012 05:09:12 +0000 (13:09 +0800)
committerChong Yidong <cyd@gnu.org>
Sat, 1 Dec 2012 05:09:12 +0000 (13:09 +0800)
* 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.

lisp/emacs-lisp/lisp-mode.el
lisp/progmodes/cperl-mode.el
lisp/progmodes/m4-mode.el
lisp/progmodes/perl-mode.el
lisp/textmodes/tex-mode.el
lisp/textmodes/texinfo.el

index 11dd6dc6ee202d812932b23759d0c2a7329b72b8..c0380c60e11e86bca376e348cd07d176ff8f7564 100644 (file)
@@ -240,28 +240,29 @@ font-lock keywords will not be case sensitive."
 
 (defun lisp-current-defun-name ()
   "Return the name of the defun at point, or nil."
-  (let ((location (point)))
-    ;; If we are now precisely at the beginning of a defun, make sure
-    ;; beginning-of-defun finds that one rather than the previous one.
-    (or (eobp) (forward-char 1))
-    (beginning-of-defun)
-    ;; Make sure we are really inside the defun found, not after it.
-    (when (and (looking-at "\\s(")
-              (progn (end-of-defun)
-                     (< location (point)))
-              (progn (forward-sexp -1)
-                     (>= location (point))))
-      (if (looking-at "\\s(")
-         (forward-char 1))
-      ;; Skip the defining construct name, typically "defun" or
-      ;; "defvar".
-      (forward-sexp 1)
-      ;; The second element is usually a symbol being defined.  If it
-      ;; is not, use the first symbol in it.
-      (skip-chars-forward " \t\n'(")
-      (buffer-substring-no-properties (point)
-                                     (progn (forward-sexp 1)
-                                            (point))))))
+  (save-excursion
+    (let ((location (point)))
+      ;; If we are now precisely at the beginning of a defun, make sure
+      ;; beginning-of-defun finds that one rather than the previous one.
+      (or (eobp) (forward-char 1))
+      (beginning-of-defun)
+      ;; Make sure we are really inside the defun found, not after it.
+      (when (and (looking-at "\\s(")
+                (progn (end-of-defun)
+                       (< location (point)))
+                (progn (forward-sexp -1)
+                       (>= location (point))))
+       (if (looking-at "\\s(")
+           (forward-char 1))
+       ;; Skip the defining construct name, typically "defun" or
+       ;; "defvar".
+       (forward-sexp 1)
+       ;; The second element is usually a symbol being defined.  If it
+       ;; is not, use the first symbol in it.
+       (skip-chars-forward " \t\n'(")
+       (buffer-substring-no-properties (point)
+                                       (progn (forward-sexp 1)
+                                              (point)))))))
 
 (defvar lisp-mode-shared-map
   (let ((map (make-sparse-keymap)))
index 5b5097803c3023929ce04be8f0ed792e01565e1b..0a952cf3870612c057b41a71283ea14ead60d900 100644 (file)
@@ -1745,8 +1745,9 @@ or as help on variables `cperl-tips', `cperl-problems',
   (make-local-variable 'add-log-current-defun-function)
   (setq add-log-current-defun-function
        (lambda ()
-         (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t)
-             (match-string-no-properties 1))))
+         (save-excursion
+           (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t)
+               (match-string-no-properties 1)))))
 
   (make-local-variable 'paragraph-start)
   (setq paragraph-start (concat "^$\\|" page-delimiter))
index 9cf98d979f6c35be28ebed9d4e8301faf0877df8..7904033e68e5f198232cc56e105e090178e6ffb4 100644 (file)
 
 (defun m4-current-defun-name ()
   "Return the name of the M4 function at point, or nil."
-  (if (re-search-backward
-       "^\\(\\(m4_\\)?define\\|A._DEFUN\\)(\\[?\\([A-Za-z0-9_]+\\)" nil t)
-      (match-string-no-properties 3)))
+  (save-excursion
+    (if (re-search-backward
+        "^\\(\\(m4_\\)?define\\|A._DEFUN\\)(\\[?\\([A-Za-z0-9_]+\\)" nil t)
+       (match-string-no-properties 3))))
 
 ;;;###autoload
 (define-derived-mode m4-mode prog-mode "m4"
index 82f742de274ce6219b2887c15236fc5d504bed3f..46940457d3601ffc9fd6a34bad0a16fadea75f8c 100644 (file)
@@ -581,8 +581,10 @@ create a new comment."
 
 (defun perl-current-defun-name ()
   "The `add-log-current-defun' function in Perl mode."
-  (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t)
-      (match-string-no-properties 1)))
+  (save-excursion
+    (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t)
+       (match-string-no-properties 1))))
+
 \f
 (defvar perl-mode-hook nil
   "Normal hook to run when entering Perl mode.")
index 966fa60e6def660e9c674bc9b86d76c547eb6b50..16689b1ad021386476ada62573970cc789552be9 100644 (file)
@@ -424,13 +424,14 @@ An alternative value is \" . \", if you use a font with a narrow period."
 
 (defun tex-current-defun-name ()
   "Return the name of the TeX section/paragraph/chapter at point, or nil."
-  (when (re-search-backward
-        "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)"
-        nil t)
-    (goto-char (match-beginning 0))
-    (buffer-substring-no-properties
-     (1+ (point))      ; without initial backslash
-     (line-end-position))))
+  (save-excursion
+    (when (re-search-backward
+          "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)"
+          nil t)
+      (goto-char (match-beginning 0))
+      (buffer-substring-no-properties
+       (1+ (point))    ; without initial backslash
+       (line-end-position)))))
 \f
 ;;;;
 ;;;; Font-Lock support
index 0e45b603c1a8a8f54e499af4e6628ae8d0c06ce1..253b56f09b11f2741ffc61bbb8632a26af5825da 100644 (file)
@@ -513,8 +513,9 @@ Subexpression 1 is what goes into the corresponding `@end' statement.")
 
 (defun texinfo-current-defun-name ()
   "Return the name of the Texinfo node at point, or nil."
-  (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t)
-      (match-string-no-properties 1)))
+  (save-excursion
+    (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t)
+       (match-string-no-properties 1))))
 
 ;;; Texinfo mode