unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Aaron S. Hawley" <aaron.s.hawley@gmail.com>
To: bug-gnu-emacs@gnu.org
Subject: bug#2379: [PATCH?] lisp.el: beginning-of-defun
Date: Wed, 18 Feb 2009 21:37:39 -0500	[thread overview]
Message-ID: <aea22dab0902181837h2e8f4a25qece67f27d2af745c@mail.gmail.com> (raw)

There's some strange programming style in `beginning-of-defun-raw' for
Emacs 22.2, perhaps this is what was meant by the use of this `progn'
syntax?

--- lisp.el	18 Feb 2009 20:56:29 -0500	1.79.2.3
+++ lisp.el	18 Feb 2009 21:07:49 -0500	
@@ -234,7 +234,7 @@
 					 "\\(?:" defun-prompt-regexp "\\)\\s(")
 			       "^\\s(")
 			     nil 'move arg)
-	 (progn (goto-char (1- (match-end 0)))) t))
+	 (progn (goto-char (1- (match-end 0))) t)))

    ;; If open-paren-in-column-0-is-defun-start and defun-prompt-regexp
    ;; are both nil, column 0 has no significance - so scan forward

If not, then this is what it probably should be:

--- lisp.el	18 Feb 2009 20:56:29 -0500	1.79.2.3
+++ lisp.el	18 Feb 2009 21:10:21 -0500	
@@ -234,7 +234,7 @@
 					 "\\(?:" defun-prompt-regexp "\\)\\s(")
 			       "^\\s(")
 			     nil 'move arg)
-	 (progn (goto-char (1- (match-end 0)))) t))
+	 (goto-char (1- (match-end 0)))))

    ;; If open-paren-in-column-0-is-defun-start and defun-prompt-regexp
    ;; are both nil, column 0 has no significance - so scan forward

Then, once that is figured out, why doesn't `beginning-of-defun'
manage zero arguments like many of the movement commands do?  Running
C-0 C-M-a seems to run `beginning-of-line' regardless.  That's an easy
fix with this patch:

--- lisp.el	18 Feb 2009 20:56:29 -0500	1.79.2.3
+++ lisp.el	18 Feb 2009 21:25:05 -0500	
@@ -204,7 +204,7 @@
       (and transient-mark-mode mark-active)
       (push-mark))
   (and (beginning-of-defun-raw arg)
-       (progn (beginning-of-line) t)))
+       (progn (if (and (integerp arg) (/= arg 0)) (beginning-of-line)) t)))

 (defun beginning-of-defun-raw (&optional arg)
   "Move point to the character that starts a defun.

But then, `beginning-of-defun-raw' seems to run (forward-char -1).
That requires this patch.


--- lisp.el	18 Feb 2009 20:56:29 -0500	1.79.2.3
+++ lisp.el	18 Feb 2009 21:28:22 -0500	
@@ -234,7 +234,7 @@
 					 "\\(?:" defun-prompt-regexp "\\)\\s(")
 			       "^\\s(")
 			     nil 'move arg)
-	 (progn (goto-char (1- (match-end 0)))) t))
+	 (progn (or (zerop arg) (goto-char (1- (match-end 0))))) t))

    ;; If open-paren-in-column-0-is-defun-start and defun-prompt-regexp
    ;; are both nil, column 0 has no significance - so scan forward

That's my best look at the situation.

Support for a zero argument in these functions is important for
situations where you want to be programmatic with
`beginning-of-defun',   Can this be fixed?

Thanks,
/a







             reply	other threads:[~2009-02-19  2:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-19  2:37 Aaron S. Hawley [this message]
2009-02-19 17:31 ` bug#2379: [PATCH?] lisp.el: beginning-of-defun Stefan Monnier
2009-02-20  4:27   ` Aaron S. Hawley
2009-02-20 15:25     ` Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aea22dab0902181837h2e8f4a25qece67f27d2af745c@mail.gmail.com \
    --to=aaron.s.hawley@gmail.com \
    --cc=2379@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).