* A plea for sanity from a frustrated hacker.
@ 2007-06-09 17:41 Alan Mackenzie
2007-06-09 16:29 ` Thien-Thi Nguyen
2007-06-09 17:59 ` Johan Bockgård
0 siblings, 2 replies; 7+ messages in thread
From: Alan Mackenzie @ 2007-06-09 17:41 UTC (permalink / raw)
To: emacs-devel
Hi, Emacs!
I'm trying to debug a bug in the help system, specifically what happens
when you hit <CR> to open the pertinent file after doing C-h f (or C-h
v).
Putting point over the file name and doing a quick C-h c <CR> revealed
that the function I wanted was `push-button'. Fair enough. A tedious
eternity of edbugging later, I've now found that .....
push-button calls
button-activate which calls
(let ((action (button-get button))) .... which returns 'help-button-action
and then calls
(funcall action ....), i.e.,
(funcall 'help-button-action #<marker at 58 in *Help*>).
help-button-action then proceeds to dredge three further lisp objects
out of the button then with them calls ....
(help-do-xref <p1> <p2> <p3>) ... which ignores <p1> then does
(apply <p2> <p2>)
So, at this stage, what is the function <p2>? It's a byte-compiled
lambda. :-( At this point, tedium and frustration have caused me to
postpone further debugging and write this rant.
Hey, Guys, this JUST ISN'T FUN. We've got six levels of calls here, none
of which do anything other than delegate actions to the next in the
nest and hoik out random lisp objects from exotic places. We've even
come through two nested `funcall'/`apply's and _still_ not got to the
real action, the function which visits the file.el and displays it in the
other window from *Help*. Would somebody help me find this function,
please?
This is reminiscent of the objectionable orientation in so many
industrial C++ programs. Can we _please_ hack with less impliciticity?
No matter how well written something is, it will need to be debugged and
changed at some point, and writing in a way so opaque it almost looks
deliberately obfuscated doesn't help. At the very least, SURELY the
final function <p2> could have been inserted as a symbol into wherever it
was rather than as a byte-compiled lambda?
This is madness. Don't worry, I'll get over it.
--
Alan Mackenzie (Ittersbach, Germany).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A plea for sanity from a frustrated hacker.
2007-06-09 17:41 A plea for sanity from a frustrated hacker Alan Mackenzie
@ 2007-06-09 16:29 ` Thien-Thi Nguyen
2007-06-09 17:59 ` Johan Bockgård
1 sibling, 0 replies; 7+ messages in thread
From: Thien-Thi Nguyen @ 2007-06-09 16:29 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
() Alan Mackenzie <acm@muc.de>
() Sat, 9 Jun 2007 18:41:30 +0100
At the very least, SURELY the final function <p2> could have been
inserted as a symbol into wherever it was rather than as a
byte-compiled lambda?
maybe it was an anonymous function to begin with; blood from a stone.
to find out what calls a function of interest (`insert-file-contents'
seems relevant here) one way is to trace execution until it is called,
which is what you did (until you gave up). another way is to put a
breakpoint on it and examine the stack when execution halts. have you
tried this?
thi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A plea for sanity from a frustrated hacker.
2007-06-09 17:41 A plea for sanity from a frustrated hacker Alan Mackenzie
2007-06-09 16:29 ` Thien-Thi Nguyen
@ 2007-06-09 17:59 ` Johan Bockgård
2007-06-09 20:20 ` Alan Mackenzie
1 sibling, 1 reply; 7+ messages in thread
From: Johan Bockgård @ 2007-06-09 17:59 UTC (permalink / raw)
To: emacs-devel
Alan Mackenzie <acm@muc.de> writes:
> Would somebody help me find this function, please?
[help-mode.el]
(define-button-type 'help-function-def
:supertype 'help-xref
'help-function (lambda (fun file)
(require 'find-func)
(when (eq file 'C-source)
(setq file
(help-C-file-name (indirect-function fun) 'fun)))
;; Don't use find-function-noselect because it follows
;; aliases (which fails for built-in functions).
(let ((location
(find-function-search-for-symbol fun nil file)))
(pop-to-buffer (car location))
(if (cdr location)
(goto-char (cdr location))
(message "Unable to find location in file"))))
'help-echo (purecopy "mouse-2, RET: find function's definition"))
--
Johan Bockgård
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A plea for sanity from a frustrated hacker.
2007-06-09 17:59 ` Johan Bockgård
@ 2007-06-09 20:20 ` Alan Mackenzie
2007-06-09 22:45 ` Juri Linkov
0 siblings, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2007-06-09 20:20 UTC (permalink / raw)
To: emacs-devel
Hi, Johan!
On Sat, Jun 09, 2007 at 07:59:16PM +0200, Johan Bockgård wrote:
> Alan Mackenzie <acm@muc.de> writes:
> > Would somebody help me find this function, please?
> [help-mode.el]
> (define-button-type 'help-function-def
> :supertype 'help-xref
> 'help-function (lambda (fun file)
> (require 'find-func)
> (when (eq file 'C-source)
> (setq file
> (help-C-file-name (indirect-function fun) 'fun)))
> ;; Don't use find-function-noselect because it follows
> ;; aliases (which fails for built-in functions).
> (let ((location
> (find-function-search-for-symbol fun nil file)))
> (pop-to-buffer (car location))
> (if (cdr location)
> (goto-char (cdr location))
> (message "Unable to find location in file"))))
> 'help-echo (purecopy "mouse-2, RET: find function's definition"))
Thanks!
> --
> Johan Bockgård
--
Alan.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A plea for sanity from a frustrated hacker.
2007-06-09 20:20 ` Alan Mackenzie
@ 2007-06-09 22:45 ` Juri Linkov
2007-06-10 3:29 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2007-06-09 22:45 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
>> > Would somebody help me find this function, please?
>
>> [help-mode.el]
>
>> (define-button-type 'help-function-def
>> :supertype 'help-xref
>> 'help-function (lambda (fun file)
>> (require 'find-func)
>> (when (eq file 'C-source)
>> (setq file
>> (help-C-file-name (indirect-function fun) 'fun)))
>> ;; Don't use find-function-noselect because it follows
>> ;; aliases (which fails for built-in functions).
>> (let ((location
>> (find-function-search-for-symbol fun nil file)))
>> (pop-to-buffer (car location))
>> (if (cdr location)
>> (goto-char (cdr location))
>> (message "Unable to find location in file"))))
>> 'help-echo (purecopy "mouse-2, RET: find function's definition"))
>
> Thanks!
The problem is that you can't arrive to this definition by studying
text properties in the *Help* buffer and debugging because
`define-button-type' doesn't define a function or variable.
BTW, I have another frustration with this function. I like to view
the Help buffer and visit source code from it in the *same* window.
The former is achieved by
(add-hook 'same-window-regexps "\\*Help\\*\\(\\|<[0-9]+>\\)")
But the latter is impossible since as can be seen in code above
`help-function-def' calls the function `pop-to-buffer' which displays
the source code buffer in a different window.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A plea for sanity from a frustrated hacker.
2007-06-09 22:45 ` Juri Linkov
@ 2007-06-10 3:29 ` Stefan Monnier
2007-06-10 14:28 ` Juri Linkov
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2007-06-10 3:29 UTC (permalink / raw)
To: Juri Linkov; +Cc: Alan Mackenzie, emacs-devel
> BTW, I have another frustration with this function. I like to view
> the Help buffer and visit source code from it in the *same* window.
> The former is achieved by
> (add-hook 'same-window-regexps "\\*Help\\*\\(\\|<[0-9]+>\\)")
> But the latter is impossible since as can be seen in code above
> `help-function-def' calls the function `pop-to-buffer' which displays
> the source code buffer in a different window.
For what it's worth, I'd hate the behavior you like.
So I don't think the code is wrong because the behavior should not be
determined by the code but by user preferences. I.e. the problem is that
the behavior of pop-to-buffer is not yet configurable enough.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A plea for sanity from a frustrated hacker.
2007-06-10 3:29 ` Stefan Monnier
@ 2007-06-10 14:28 ` Juri Linkov
0 siblings, 0 replies; 7+ messages in thread
From: Juri Linkov @ 2007-06-10 14:28 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
>> BTW, I have another frustration with this function. I like to view
>> the Help buffer and visit source code from it in the *same* window.
>> The former is achieved by
>
>> (add-hook 'same-window-regexps "\\*Help\\*\\(\\|<[0-9]+>\\)")
>
>> But the latter is impossible since as can be seen in code above
>> `help-function-def' calls the function `pop-to-buffer' which displays
>> the source code buffer in a different window.
>
> For what it's worth, I'd hate the behavior you like.
> So I don't think the code is wrong because the behavior should not be
> determined by the code but by user preferences. I.e. the problem is that
> the behavior of pop-to-buffer is not yet configurable enough.
That's exactly what I meant. pop-to-buffer doesn't allow configuring its
behavior to display the source buffer in the same Help window. I don't argue
for changing its default behavior.
How about adding a new user option, e.g `same-window-regexps-from'?
By analogy with `same-window-regexps' it will contain a list of regexps
saying that displaying a buffer from these buffers should appear in the
same window.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-06-10 14:28 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-09 17:41 A plea for sanity from a frustrated hacker Alan Mackenzie
2007-06-09 16:29 ` Thien-Thi Nguyen
2007-06-09 17:59 ` Johan Bockgård
2007-06-09 20:20 ` Alan Mackenzie
2007-06-09 22:45 ` Juri Linkov
2007-06-10 3:29 ` Stefan Monnier
2007-06-10 14:28 ` Juri Linkov
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.