all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mark Lillibridge <mdl@alum.mit.edu>
To: 13305@debbugs.gnu.org
Subject: bug#13305: 24.2; describe-function gives incorrect function location information (for functions changed in a hook?)
Date: Sat, 29 Dec 2012 12:16:09 -0800	[thread overview]
Message-ID: <87ehi8ty0m.fsf@foil.strangled.net> (raw)


    While working on a patch, I ran into a really weird and misleading
case where describe-function lied about where a function was located,
making me think my redefinition of the function had been ignored.

Here's a recipe to reproduce the problem:

    Start with emacs -q, do M-: (require 'rmailsum), then use C-h f on
rmail-summary-output; you should (correctly) see:

    rmail-summary-output is an interactive compiled Lisp function in
    `rmailsum.el'.
    
    (rmail-summary-output &optional FILE-NAME N)
    
    Append this message to mail file FILE-NAME.
    This works with both mbox format and Babyl format files,
    outputting in the appropriate format for each.
    The default file name comes from `rmail-default-file',
    which is updated to the name you use in this command.
    
    A prefix argument N says to output that many consecutive messages
    from those in the summary, starting with the current one.
    Deleted messages are skipped and don't count.
    When called from Lisp code, N may be omitted and defaults to 1.
    
    This command always outputs the complete message header,
    even the header display is currently pruned.

Note that the location of the function is correctly given as in rmailsum.el.


    Now start again with emacs -q then evaluate the following elisp
code:

====================  cut here for elisp ====================
(add-hook 'rmail-mode-hook
  (function (lambda()

(require 'rmailsum)

(defun rmail-summary-output (&optional file-name n)
  "MODIFIED!
Append this message to mail file FILE-NAME.
This works with both mbox format and Babyl format files,
outputting in the appropriate format for each.
The default file name comes from `rmail-default-file',
which is updated to the name you use in this command.

A prefix argument N says to output that many consecutive messages
from those in the summary, starting with the current one.
Deleted messages are skipped and don't count.
When called from Lisp code, N may be omitted and defaults to 1.

This command always outputs the complete message header,
even the header display is currently pruned.
[mdl: patched for bug #12214]"
  (interactive
   (progn (require 'rmailout)
	  (list (with-current-buffer rmail-buffer (rmail-output-read-file-name))
		(prefix-numeric-value current-prefix-arg))))
  (let ((i 0) prev-msg)
    (while
	(and (< i n)
	     (progn (rmail-summary-goto-msg)
		    (not (eq prev-msg
			     (setq prev-msg
				   (with-current-buffer rmail-buffer
				     rmail-current-message))))))
      (setq i (1+ i))
      (with-current-buffer rmail-buffer
	(let ((rmail-delete-after-output nil))
	  (with-no-warnings (rmail-output file-name 1))))
      (if rmail-delete-after-output
	  (rmail-summary-delete-forward nil)
	(if (< i n)
	    (rmail-summary-next-msg 1))))))

)))
====================  cut here for elisp ====================

    Basically, this replaces the built-in version of
rmail-summary-output with a patched version; the patching is done only
when Rmail started via the Rmail mode hook (I don't always use Rmail
mode and don't want to unnecessarily load things to save on start up
speed with slow connections).

    Now do M-x rmail then once again C-h f on rmail-summary-output; you
should (incorrectly) see:

    rmail-summary-output is an interactive Lisp function in `rmailsum.el'.
    
    (rmail-summary-output &optional FILE-NAME N)
    
    MODIFIED!
    Append this message to mail file FILE-NAME.
    This works with both mbox format and Babyl format files,
    outputting in the appropriate format for each.
    The default file name comes from `rmail-default-file',
    which is updated to the name you use in this command.
    
    A prefix argument N says to output that many consecutive messages
    from those in the summary, starting with the current one.
    Deleted messages are skipped and don't count.
    When called from Lisp code, N may be omitted and defaults to 1.
    
    This command always outputs the complete message header,
    even the header display is currently pruned.
    [mdl: patched for bug #12214]

Note that the modification has been made (see the MODIFIED! at the top)
*BUT* help still thinks the function is located in rmailsum.el.


    By contrast, if I do the patching outside of the Rmail mode hook,
(emacs -q, eval all but first 2 and last line, M-x rmail, then C-h f) I
get:

    rmail-summary-output is an interactive Lisp function in `temporary'.
    
    (rmail-summary-output &optional FILE-NAME N)
    
    MODIFIED!
    Append this message to mail file FILE-NAME.
    This works with both mbox format and Babyl format files,
    outputting in the appropriate format for each.
    The default file name comes from `rmail-default-file',
    which is updated to the name you use in this command.
    
    A prefix argument N says to output that many consecutive messages
    from those in the summary, starting with the current one.
    Deleted messages are skipped and don't count.
    When called from Lisp code, N may be omitted and defaults to 1.
    
    This command always outputs the complete message header,
    even the header display is currently pruned.
    [mdl: patched for bug #12214]

(temporary is the name of the file I evaluated the list from).

- Mark





             reply	other threads:[~2012-12-29 20:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-29 20:16 Mark Lillibridge [this message]
2012-12-31  2:57 ` bug#13305: 24.2; describe-function gives incorrect function location information (for functions changed in a hook?) Stefan Monnier
2013-01-01 19:34   ` Mark Lillibridge
2013-01-03 17:22     ` Stefan Monnier
2013-01-23  2:16     ` Stefan Monnier
2012-12-31  2:59 ` Stefan Monnier
2013-01-01 19:35   ` Mark Lillibridge
2013-01-03 17:19     ` 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

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

  git send-email \
    --in-reply-to=87ehi8ty0m.fsf@foil.strangled.net \
    --to=mdl@alum.mit.edu \
    --cc=13305@debbugs.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.