From: Marcin Borkowski <mbork@mbork.pl>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Strange behavior of (beginning-of-defun 0)
Date: Wed, 22 Feb 2017 10:13:29 +0100 [thread overview]
Message-ID: <87o9xumvuu.fsf@jane> (raw)
In-Reply-To: <87r339s12a.fsf@mbork.pl>
[-- Attachment #1: Type: text/plain, Size: 984 bytes --]
On 2017-02-08, at 06:29, Marcin Borkowski <mbork@mbork.pl> wrote:
> Hi all,
>
> put this in an Elisp buffer:
>
> --8<---------------cut here---------------start------------->8---
> (defun a ()
> nil)
> -!-(defun b ()
> nil)
> --8<---------------cut here---------------end--------------->8---
>
> put the point where the -!- is (of course, "-!-" is only a marker and
> should not be in the buffer;-)) and say M-: (beginning-of-defun 0) (or
> C-u 0 C-M-a). The point goes up one line.
>
> Is that intended? Is the behavior of (beginning-of-defun 0) defined at
> all?
Hi all,
I spent a few minutes looking into this, and it seems that while a test
for zero argument is actually present in `beginning-of-defun-raw', it
(a) is (imho) located in the wrong place (too late in the `cond') and
(b) returns t instead of nil (so that `beginning-of-defun' moves to the
bol instead of not moving the point at all). So, here's a patch
correcting this. WDYT?
Best,
--
Marcin Borkowski
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-beginning-of-defun-raw-0.patch --]
[-- Type: text/x-diff, Size: 1312 bytes --]
From daf641a0c57bd8fdcf1fad40bcfbc23a8fb40101 Mon Sep 17 00:00:00 2001
From: Marcin Borkowski <mbork@mbork.pl>
Date: Wed, 22 Feb 2017 10:02:47 +0100
Subject: [PATCH] Fix (beginning-of-defun-raw 0)
* lisp/emacs-lisp/lisp.el (beginning-of-defun-raw): fix
behavior with arg equal to zero
Unless `beginning-of-defun-function' is non-nil (and should take care
of that situation), do nothing when argument is 0.
---
lisp/emacs-lisp/lisp.el | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 0172e3af26..b2dd8edf42 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -337,6 +337,8 @@ beginning-of-defun-raw
(dotimes (_ (- arg))
(funcall end-of-defun-function))))))
+ ((eq arg 0) nil)
+
((or defun-prompt-regexp open-paren-in-column-0-is-defun-start)
(and (< arg 0) (not (eobp)) (forward-char 1))
(and (re-search-backward (if defun-prompt-regexp
@@ -356,8 +358,6 @@ beginning-of-defun-raw
;; call to scan-lists below can be extremely slow. This is because
;; back_comment in syntax.c may have to scan from bob to find the
;; beginning of each comment. Fixing this is not trivial -- cyd.
-
- ((eq arg 0))
(t
(let ((floor (point-min))
(ceiling (point-max))
--
2.11.1
prev parent reply other threads:[~2017-02-22 9:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-08 5:29 Strange behavior of (beginning-of-defun 0) Marcin Borkowski
2017-02-22 9:13 ` Marcin Borkowski [this message]
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=87o9xumvuu.fsf@jane \
--to=mbork@mbork.pl \
--cc=emacs-devel@gnu.org \
/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.