unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: MON KEY <monkey@sandpframing.com>
To: 6462@debbugs.gnu.org
Subject: bug#6462: `disabled-command-function' corrupts the `help-xref-stack'
Date: Fri, 18 Jun 2010 17:17:00 -0400	[thread overview]
Message-ID: <AANLkTikU8xXHqUPDksxtYcMOoZPqC6Wr9t1CXkYCOH5j@mail.gmail.com> (raw)

The `disabled-command-function's window-excursion via
`help-setup-xref'->`with-output-to-temp-buffer' can corrupt the
`help-xref-stack' b/c/ of with these lines:

,----
| (help-setup-xref (list 'disabled-command-function cmd keys) nil)
|       (with-output-to-temp-buffer "*Disabled Command*" ;; (help-buffer)
`----

The present functionality is brainded because the "*Disabled Command*"
stays on the `help-xref-stack'.

This is stupid because `disabled-command-function' grabs all keyboard
input except `keyboard-quit' so it is not realistic for the user to
inspect the `goal-column' variable via `help-mode's xrefs anyway.

Moreover, because `with-output-to-temp-buffer' spits its message to the
"*Disabled-Command*" buffer we now have a broken/compromized
`help-xref-stack' _and_ a lingering "*Disabled-Command*" buffer which
lacks any buttonized navigation (though these buttons wouldn't
function correctly even if they were there)

Noteic, the commented sources above indicate that at some point the
output may have gone to the value of (help-buffer). Though, I don't
quite get why `disabled-command-function' is be piggybacking on
`help-setup-xref' in the first place.

Regardless, disabled-command-function should take care better care to
clean up after itself by:

 a) removing itself from the `help-xref-stack'

 b) detecting inside an unwind-protect whether `last-command' was a
    `keyboard-quit' and if so automatically deleting itself (no
    questions asked). You've already stolen my keyboard out from under
    me, there is no reason to leave this buffer laying around esp. as
    its gonna keep popping up again and again anyways.

A recipe to reproduce the offending behavior:

(progn
  (when (get-buffer "*Help*")
    (kill-buffer (get-buffer "*Help*")))
  (unless (get 'set-goal-column 'disabled)
    (put 'set-goal-column 'disabled t))
  (describe-function  'enable-command)
  (with-current-buffer (get-buffer "*Help*")
    (describe-function  'disabled-command-function)
    (help-go-back))
  (pop-to-buffer (get-buffer "*Help*")))

Tickle the command-loop to trigger on `set-goal-column' by typing:

 "C-x C-n"

Tell the `disabled-command-function' to get f*cked by typing:

 "n"

Remap `set-goal-column' to something irrelevant:

 (define-key ctl-x-map [remap set-goal-column]  'ignore)

Now navigate through the `help-xref-stack' with either:
 "C-c C-b" `help-go-back'
 "C-C C-f" `help-go-forward'

You should eventually run into the "*Disabled Command*" buffer.

At which point `disabled-command-function' should then proceed to grab
your keyboard and ask you to "select Y/N SPC !".

Tell it to get f*cked again. (try "C-k" this time just for kicks)

Scratch head for a moment before determining that while the following
will fix one problem it will create others:

 (setq disabled-command-function  'ignore) ;; 'undefined)

Cleanup the mess we've made by putting `set-goal-column' back on the
ctl-x-map and enable/disable it:

 (define-key ctl-x-map "\C-n" 'set-goal-column)

 (put 'set-goal-column 'disabled { nil | t } ))


Verified with Emacs "23.2.1" emacs -Q

Verified current through lisp/novice.el sources circa bzr revision 100577

--
/s_P\





             reply	other threads:[~2010-06-18 21:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-18 21:17 MON KEY [this message]
2011-03-03 17:57 ` bug#6462: bug#8147: 24.0.50; Inserting *Help* buffer can lead to data loss MON KEY
2021-06-03  8:43 ` bug#6462: `disabled-command-function' corrupts the `help-xref-stack' Lars Ingebrigtsen
2021-07-01 11:43   ` Lars Ingebrigtsen

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=AANLkTikU8xXHqUPDksxtYcMOoZPqC6Wr9t1CXkYCOH5j@mail.gmail.com \
    --to=monkey@sandpframing.com \
    --cc=6462@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 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).