emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-24 r107861: `narrow-to-defun' fixup


From: Lars Magne Ingebrigtsen
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r107861: `narrow-to-defun' fixup
Date: Fri, 02 Nov 2012 02:14:56 -0000
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 107861
fixes bug: http://debbugs.gnu.org/6157
author: Lennart Borgman <address@hidden>
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Wed 2012-04-11 04:12:20 +0200
message:
  `narrow-to-defun' fixup
  
  * emacs-lisp/lisp.el (narrow-to-defun): `beginning-of-defun' goes
  to previous function when point is on the first character of a
  function. Take care of that in `narrow-to-defun'.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/lisp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-04-11 02:06:59 +0000
+++ b/lisp/ChangeLog    2012-04-11 02:12:20 +0000
@@ -1,3 +1,9 @@
+2012-04-11  Lennart Borgman  <address@hidden>
+
+       * emacs-lisp/lisp.el (narrow-to-defun): `beginning-of-defun' goes
+       to previous function when point is on the first character of a
+       function. Take care of that in `narrow-to-defun' (bug#6157).
+
 2012-04-11  Glenn Morris  <address@hidden>
 
        * vc/vc-bzr.el (vc-bzr-status): Handle all errors,

=== modified file 'lisp/emacs-lisp/lisp.el'
--- a/lisp/emacs-lisp/lisp.el   2012-02-23 08:13:48 +0000
+++ b/lisp/emacs-lisp/lisp.el   2012-04-11 02:12:20 +0000
@@ -447,7 +447,21 @@
       ;; Try first in this order for the sake of languages with nested
       ;; functions where several can end at the same place as with
       ;; the offside rule, e.g. Python.
-      (beginning-of-defun)
+
+      ;; Finding the start of the function is a bit problematic since
+      ;; `beginning-of-defun' when we are on the first character of
+      ;; the function might go to the previous function.
+      ;;
+      ;; Therefore we first move one character forward and then call
+      ;; `beginning-of-defun'.  However now we must check that we did
+      ;; not move into the next function.
+      (let ((here (point)))
+        (unless (eolp)
+         (forward-char))
+        (beginning-of-defun)
+        (when (< (point) here)
+          (goto-char here)
+          (beginning-of-defun)))
       (setq beg (point))
       (end-of-defun)
       (setq end (point))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]