unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplement list-processes in Lisp.
       [not found] <E1Q7a6k-0006uE-Q0@colonialone.fsf.org>
@ 2011-04-06 22:35 ` Juanma Barranquero
  2011-04-07  0:38   ` Chong Yidong
  0 siblings, 1 reply; 12+ messages in thread
From: Juanma Barranquero @ 2011-04-06 22:35 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Emacs developers

On Wed, Apr 6, 2011 at 23:13, Chong Yidong <cyd@stupidchicken.com> wrote:

> revno: 103854
> committer: Chong Yidong <cyd@stupidchicken.com>
> branch nick: trunk
> timestamp: Wed 2011-04-06 17:13:17 -0400
> message:
>  Reimplement list-processes in Lisp.

Looks much nicer that the C version.

One small difference, though: it does not respect temp-buffer-resize-mode.

    Juanma



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplement list-processes in Lisp.
  2011-04-06 22:35 ` [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplement list-processes in Lisp Juanma Barranquero
@ 2011-04-07  0:38   ` Chong Yidong
  2011-04-07  0:57     ` Juanma Barranquero
  2011-04-07  2:00     ` [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes " Drew Adams
  0 siblings, 2 replies; 12+ messages in thread
From: Chong Yidong @ 2011-04-07  0:38 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

Juanma Barranquero <lekktu@gmail.com> writes:

> On Wed, Apr 6, 2011 at 23:13, Chong Yidong <cyd@stupidchicken.com> wrote:
>
>> revno: 103854
>> committer: Chong Yidong <cyd@stupidchicken.com>
>> branch nick: trunk
>> timestamp: Wed 2011-04-06 17:13:17 -0400
>> message:
>> Reimplement list-processes in Lisp.
>
> Looks much nicer that the C version.
>
> One small difference, though: it does not respect temp-buffer-resize-mode.

The documentation for temp-buffer-show-hook is somewhat vacuous---it
says that it's the hook run by with-output-to-temp-buffer.  Because the
new implementation doesn't use with-output-to-temp-buffer, it doesn't
run the hook.

Should it?  Note that list-buffers does not either.

Maybe temp-buffer-show-hook/temp-buffer-resize-mode needs a bit of a
rethink.  IIUC, this hook was intended for "disposable" buffers that
temporarily display information but do not provide any other useful
interaction.  But that hasn't even been the case for the *Help* buffers
for a long time, since those now contain clickable text buttons.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplement list-processes in Lisp.
  2011-04-07  0:38   ` Chong Yidong
@ 2011-04-07  0:57     ` Juanma Barranquero
  2011-04-07  2:00     ` [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes " Drew Adams
  1 sibling, 0 replies; 12+ messages in thread
From: Juanma Barranquero @ 2011-04-07  0:57 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Emacs developers

On Thu, Apr 7, 2011 at 02:38, Chong Yidong <cyd@stupidchicken.com> wrote:

> The documentation for temp-buffer-show-hook is somewhat vacuous---

For generous values of "somewhat", yeah.

> it
> says that it's the hook run by with-output-to-temp-buffer.  Because the
> new implementation doesn't use with-output-to-temp-buffer, it doesn't
> run the hook.

Well, the problem is that with the current list-processes:

  (unless (bufferp buffer)
    (setq buffer (get-buffer-create "*Process List*")))
  (with-current-buffer buffer
    (process-menu-mode)   ;; <--- process-menu-mode-hook
    (setq process-menu-query-only query-only)
    (list-processes--refresh)
    (tabulated-list-print))
  (display-buffer buffer))  ;; <--- showing the contents

the point at which the available hook is run is way too early to make
adding `fit-window-to-buffer' or `resize-temp-buffer-window' useful.
And display-buffer does not run any hook. So the only fix is either a
defadvice, or a wrapper function.

> Should it?  Note that list-buffers does not either.

I hadn't noticed because I don't ever use it (I have bs-show bound to
a single key, <apps>); but I think resizing should work with
list-buffers too.

> Maybe temp-buffer-show-hook/temp-buffer-resize-mode needs a bit of a
> rethink.  IIUC, this hook was intended for "disposable" buffers that
> temporarily display information but do not provide any other useful
> interaction.  But that hasn't even been the case for the *Help* buffers
> for a long time, since those now contain clickable text buttons.

Certainly, `temp-buffer-resize-mode' is useful for non-"disposable"
buffers. Resizing is not related to the lifetime of the buffer
contents.

    Juanma



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes in Lisp.
  2011-04-07  0:38   ` Chong Yidong
  2011-04-07  0:57     ` Juanma Barranquero
@ 2011-04-07  2:00     ` Drew Adams
  2011-04-07 10:09       ` Juanma Barranquero
  1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2011-04-07  2:00 UTC (permalink / raw)
  To: 'Chong Yidong', 'Juanma Barranquero'
  Cc: 'Emacs developers'

> Maybe temp-buffer-show-hook/temp-buffer-resize-mode needs a bit of a
> rethink.  IIUC, this hook was intended for "disposable" buffers that
> temporarily display information but do not provide any other useful
> interaction.  But that hasn't even been the case for the *Help*
> buffers for a long time, since those now contain clickable
> text buttons.

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8368




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes in Lisp.
  2011-04-07  2:00     ` [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes " Drew Adams
@ 2011-04-07 10:09       ` Juanma Barranquero
  2011-04-07 15:59         ` Chong Yidong
  0 siblings, 1 reply; 12+ messages in thread
From: Juanma Barranquero @ 2011-04-07 10:09 UTC (permalink / raw)
  To: Drew Adams; +Cc: Chong Yidong, Emacs developers

> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8368

Thanks, I had forgotten that report.

I basically agree with the first part, i.e., that it's a mistake to
assume any relationship between temporary and help.

    Juanma



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes in Lisp.
  2011-04-07 10:09       ` Juanma Barranquero
@ 2011-04-07 15:59         ` Chong Yidong
  2011-04-07 17:00           ` Drew Adams
  2011-04-08  7:25           ` martin rudalics
  0 siblings, 2 replies; 12+ messages in thread
From: Chong Yidong @ 2011-04-07 15:59 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Drew Adams, Emacs developers

Juanma Barranquero <lekktu@gmail.com> writes:

>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8368
>
> Thanks, I had forgotten that report.
>
> I basically agree with the first part, i.e., that it's a mistake to
> assume any relationship between temporary and help.

Now that we have with-help-window (added by Martin Rudalics in 2007), it
makes sense to put help-mode-setup and help-mode-finish there, rather
than applying them to all with-output-to-temp-buffer calls.

Some uses of temp_output_buffer_setup in the C code may need to be fixed
to call help-mode-* explicitly, but that should be easy.

As for temp-buffer-setup-hook itself, maybe we should deprecate it.
(The name is confusing, since with-temp-buffer does not run it when
setting up the buffer.)  AFAICT, anything you put in the hook can be
accomplished equivalently using the with-output-to-temp-buffer body (one
difference is that the hook is run before rebinding standard-output, but
probably no one needs this).  So, with help-mode-setup moved out into
with-help-window, we can dispense with this hook.

As for list-* commands not obeying temp-buffer-resize-mode, how about
adding a display-buffer-hook, renaming temp-buffer-resize-mode to
display-buffer-resize-mode (and moving it from help.el to window.el),
and making that mode act on all uses of display-buffer-hook?  Then we
can probably either deprecate temp-buffer-show-hook or make it an alias
for display-buffer-hook.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes in Lisp.
  2011-04-07 15:59         ` Chong Yidong
@ 2011-04-07 17:00           ` Drew Adams
  2011-04-07 19:08             ` Chong Yidong
  2011-04-08  7:25           ` martin rudalics
  1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2011-04-07 17:00 UTC (permalink / raw)
  To: 'Chong Yidong', 'Juanma Barranquero'
  Cc: 'Emacs developers'

> > > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8368
> >
> > Thanks, I had forgotten that report.
> >
> > I basically agree with the first part, i.e., that it's a mistake to
> > assume any relationship between temporary and help.
> 
> Now that we have with-help-window (added by Martin Rudalics 
> in 2007), it makes sense to put help-mode-setup and
> help-mode-finish there, rather than applying them to all
> with-output-to-temp-buffer calls.
>
> Some uses of temp_output_buffer_setup in the C code may need 
> to be fixed to call help-mode-* explicitly, but that should be easy.
> 
> As for temp-buffer-setup-hook itself, maybe we should deprecate it.

Please be careful in this regard.  The use of help stuff for "temporary" buffers
is now quite old.  Lots of code out there expects it.

As I mentioned in the bug #8368 report, I'd suggest just aliasing to rename
`*-temp-*' to `*-help-*', and then creating a separate, _real_ temporary buffer
functionality that would not involve anything help- or completion-related.

IOW, just call things as they really are, but don't change or get rid of any
functionality.  From that moment on, users would see and use `*-help-*' where
they used to use `*-temp-*', and any old code with `*-temp-*' references would
still work the same.  The new, real temporary-buffer stuff would have a
different name (e.g. `*-temporary-*') so there would be no ambiguity or
conflict.

Deprecating the hook would be unwise, IMO.  It is used by 3rd-party code, if not
by vanilla Emacs code.  It should simply be renamed to `help-buffer-setup-hook'
and be run exactly as it is today (in the renamed `with-output-to-temp-buffer',
aka `with-output-to-help-buffer').  No changes in functionality.  No surprises.
Just make the names and the doc make better sense from now on.

> (The name is confusing, since with-temp-buffer does not run it when
> setting up the buffer.)

(I think you meant `with-output-to-temp-buffer'?)

Depends what you mean by "setting up".  It is run just after erasing the buffer.
Seems like pretty much the moment of buffer setup, to me.

> AFAICT, anything you put in the hook can be accomplished
> equivalently using the with-output-to-temp-buffer body

Hooks can be bound (dynamically), changing code behavior.  Sure, you can put a
function variable into the body, to get a similar effect, but that's essentially
using a hook!

Anyway, what you say is true of lots of hooks: given access to the body they can
be done without.  There's nothing wrong with keeping this hook.  And it is no
doubt used in 3rd-party code.

> (one difference is that the hook is run before rebinding 
> standard-output, but probably no one needs this).
> So, with help-mode-setup moved out into
> with-help-window, we can dispense with this hook.

Why move it to something that has to do with a window (display)?  Why move it
anywhere?  The only real problem (see the bug report) is the possible confusion
over naming.

> As for list-* commands not obeying temp-buffer-resize-mode, how about
> adding a display-buffer-hook, renaming temp-buffer-resize-mode to
> display-buffer-resize-mode (and moving it from help.el to window.el),
> and making that mode act on all uses of display-buffer-hook?  Then we
> can probably either deprecate temp-buffer-show-hook or make 
> it an alias for display-buffer-hook.

I don't see why you're thinking of doing all of this.  What is the problem
(problems?) you are trying to solve by this manoeuver?




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes in Lisp.
  2011-04-07 17:00           ` Drew Adams
@ 2011-04-07 19:08             ` Chong Yidong
  2011-04-08  7:25               ` martin rudalics
  0 siblings, 1 reply; 12+ messages in thread
From: Chong Yidong @ 2011-04-07 19:08 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Juanma Barranquero', 'Emacs developers'

"Drew Adams" <drew.adams@oracle.com> writes:

>> (The name is confusing, since with-temp-buffer does not run it when
>> setting up the buffer.)
>
> (I think you meant `with-output-to-temp-buffer'?)

No, I mean with-temp-buffer.

> I don't see why you're thinking of doing all of this.  What is the
> problem (problems?) you are trying to solve by this manoeuver?

See OP: temp-buffer-resize-mode is limited to buffers made from
with-output-to-temp-buffer.  Doing it for the general display-buffer
case makes more sense, but, as Juanma pointed out, there is currently no
simple way to do this.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes in Lisp.
  2011-04-07 15:59         ` Chong Yidong
  2011-04-07 17:00           ` Drew Adams
@ 2011-04-08  7:25           ` martin rudalics
  1 sibling, 0 replies; 12+ messages in thread
From: martin rudalics @ 2011-04-08  7:25 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Juanma Barranquero, Drew Adams, Emacs developers

 > As for list-* commands not obeying temp-buffer-resize-mode, how about
 > adding a display-buffer-hook, renaming temp-buffer-resize-mode to
 > display-buffer-resize-mode (and moving it from help.el to window.el),
 > and making that mode act on all uses of display-buffer-hook?  Then we
 > can probably either deprecate temp-buffer-show-hook or make it an alias
 > for display-buffer-hook.

`temp-buffer-resize-mode' is a misnomer since it applies only to the
initial display of the buffer.  When the corresponding window is resized
or text is rescaled it usually misses to make the "window the right
height for its contents".  So we should either call this something like
`display-buffer-fit-window-to-buffer' or devise a function hooking into
window configuration changes and text rescaling to make a mode that
really does what it advertises.  Which also means that the associated
windows should be fixed size most of the time.

martin



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes in Lisp.
  2011-04-07 19:08             ` Chong Yidong
@ 2011-04-08  7:25               ` martin rudalics
  2011-04-08 11:03                 ` Juanma Barranquero
  0 siblings, 1 reply; 12+ messages in thread
From: martin rudalics @ 2011-04-08  7:25 UTC (permalink / raw)
  To: Chong Yidong
  Cc: 'Juanma Barranquero', Drew Adams,
	'Emacs developers'

 > See OP: temp-buffer-resize-mode is limited to buffers made from
 > with-output-to-temp-buffer.  Doing it for the general display-buffer
 > case makes more sense, but, as Juanma pointed out, there is currently no
 > simple way to do this.

The most simple way I can think of is

(defun display-buffer-fit-window-to-buffer (buffer-or-name &optional not-this-window frame)
   (let* (display-buffer-function
	 (window
	  (display-buffer buffer-or-name not-this-window frame)))
     (fit-window-to-buffer window)
     window))

(setq display-buffer-function 'display-buffer-fit-window-to-buffer)

martin



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes in Lisp.
  2011-04-08  7:25               ` martin rudalics
@ 2011-04-08 11:03                 ` Juanma Barranquero
  2011-04-08 12:26                   ` martin rudalics
  0 siblings, 1 reply; 12+ messages in thread
From: Juanma Barranquero @ 2011-04-08 11:03 UTC (permalink / raw)
  To: martin rudalics; +Cc: Chong Yidong, Drew Adams, Emacs developers

On Fri, Apr 8, 2011 at 09:25, martin rudalics <rudalics@gmx.at> wrote:

> The most simple way I can think of is

Nice, but

> (defun display-buffer-fit-window-to-buffer (buffer-or-name &optional
> not-this-window frame)
>  (let* (display-buffer-function
>         (window
>          (display-buffer buffer-or-name not-this-window frame)))
>    (fit-window-to-buffer window)
>    window))

who passes the FRAME argument? Because the docstring of
`display-buffer-function' speaks only of buffer-or-name and
not-this-window.

    Juanma



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes in Lisp.
  2011-04-08 11:03                 ` Juanma Barranquero
@ 2011-04-08 12:26                   ` martin rudalics
  0 siblings, 0 replies; 12+ messages in thread
From: martin rudalics @ 2011-04-08 12:26 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Chong Yidong, Drew Adams, Emacs developers

 > Nice, but
[...]
 > who passes the FRAME argument?

;-)

 > Because the docstring of
 > `display-buffer-function' speaks only of buffer-or-name and
 > not-this-window.

Indeed.  Whoever added the FRAME argument didn't think about
`display-buffer-function'

martin



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-04-08 12:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <E1Q7a6k-0006uE-Q0@colonialone.fsf.org>
2011-04-06 22:35 ` [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplement list-processes in Lisp Juanma Barranquero
2011-04-07  0:38   ` Chong Yidong
2011-04-07  0:57     ` Juanma Barranquero
2011-04-07  2:00     ` [Emacs-diffs] /srv/bzr/emacs/trunk r103854: Reimplementlist-processes " Drew Adams
2011-04-07 10:09       ` Juanma Barranquero
2011-04-07 15:59         ` Chong Yidong
2011-04-07 17:00           ` Drew Adams
2011-04-07 19:08             ` Chong Yidong
2011-04-08  7:25               ` martin rudalics
2011-04-08 11:03                 ` Juanma Barranquero
2011-04-08 12:26                   ` martin rudalics
2011-04-08  7:25           ` martin rudalics

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).