From: Lars Magne Ingebrigtsen <larsi@gnus.org>
To: Lennart Borgman <lennart.borgman@gmail.com>
Cc: 6157@debbugs.gnu.org
Subject: bug#6157: narrow-to-defun fix when point is on function beginning
Date: Wed, 21 Sep 2011 22:03:24 +0200 [thread overview]
Message-ID: <m3ipoly86r.fsf@stories.gnus.org> (raw)
In-Reply-To: <s2pe01d8a51005100751u77a3c88brb26deef60ccd3dad@mail.gmail.com> (Lennart Borgman's message of "Mon, 10 May 2010 16:51:11 +0200")
Lennart Borgman <lennart.borgman@gmail.com> writes:
> `beginning-of-defun' goes to previous function when point is on the
> first character of a function. This is not currently taken care of in
> `narrow-to-defun'. This patch fixes this:
>
> c:\emacs-lp\bld\emacs\emacsw32\lisp\emacs-lisp>bzr diff --old
> c:\emacs-lp\bld\emacs\trunk -p trunk/:patched/ lisp.el
> === modified file 'lisp/emacs-lisp/lisp.el'
> --- trunk/lisp/emacs-lisp/lisp.el 2010-04-27 17:57:32 +0000
> +++ patched/lisp/emacs-lisp/lisp.el 2010-05-10 14:21:59 +0000
> @@ -438,7 +438,20 @@
> ;; 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.
> + ;;
> + ;; Therefor 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 (eobp) (forward-char))
> + (beginning-of-defun)
> + (when (< (point) here)
> + (goto-char here)
> + (beginning-of-defun)))
> (setq beg (point))
> (end-of-defun)
> (setq end (point))
This patch was apparently approved by Stefan, but not applied, as far as
I can tell. Did it turn out to not be correct after all?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
next prev parent reply other threads:[~2011-09-21 20:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-10 14:51 bug#6157: narrow-to-defun fix when point is on function beginning Lennart Borgman
2010-05-10 17:06 ` Stefan Monnier
2011-09-21 20:03 ` Lars Magne Ingebrigtsen [this message]
2011-09-21 20:19 ` Lennart Borgman
2012-04-11 2:11 ` Lars Magne Ingebrigtsen
2012-04-11 9:47 ` Lennart Borgman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3ipoly86r.fsf@stories.gnus.org \
--to=larsi@gnus.org \
--cc=6157@debbugs.gnu.org \
--cc=lennart.borgman@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.