unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented
@ 2012-11-10 19:18 Michael Heerdegen
  2012-11-10 19:42 ` Michael Heerdegen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michael Heerdegen @ 2012-11-10 19:18 UTC (permalink / raw)
  To: 12854

Hi,

The doc says:

> display-buffer-alist is a variable defined in `window.el'.
> [...]
> 
> Alist of conditional actions for `display-buffer'.
> This is a list of elements (CONDITION . ACTION), where:
> 
>  CONDITION is either a regexp matching buffer names, or a function
>   that takes a buffer and returns a boolean.

But the CONDITION is handled very differently by
`display-buffer-assq-regexp':

(defun display-buffer-assq-regexp (buffer-name alist)
  "Retrieve ALIST entry corresponding to BUFFER-NAME."
  (catch 'match
    (dolist (entry alist)
      (let ((key (car entry)))
	(when (or (and (stringp key)
		       (string-match-p key buffer-name))
		  (and (symbolp key) (functionp key)
		       (funcall key buffer-name alist)))
	  (throw 'match (cdr entry)))))))


Obviously, two things are wrong here:

(1) If CONDITION is a function, it currently must be a symbol.  I don't
see why lambda expressions should be forbidden.  The user should not
need to use defun only to be able specify an argument.

(2) If CONDITION is a function, it takes _two_ arguments: a buffer
_name_ (not a buffer) _and_ an alist.  That should be clarified in the
docstring.


Regards,

Michael.
    





In GNU Emacs 24.2.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2)
 of 2012-11-01 on dex, modified by Debian
 (emacs-snapshot package, version 2:20121101-1)
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
System Description:	Debian GNU/Linux testing (wheezy)






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

* bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented
  2012-11-10 19:18 bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented Michael Heerdegen
@ 2012-11-10 19:42 ` Michael Heerdegen
  2012-11-16 15:33   ` martin rudalics
  2012-11-13 13:50 ` martin rudalics
  2012-11-16 15:32 ` martin rudalics
  2 siblings, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2012-11-10 19:42 UTC (permalink / raw)
  To: 12854

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Hi,
>
> The doc says:
>
> > display-buffer-alist is a variable defined in `window.el'.
> > [...]
> > 
> > Alist of conditional actions for `display-buffer'.
> > This is a list of elements (CONDITION . ACTION), where:
> > 
> >  CONDITION is either a regexp matching buffer names, or a function
> >   that takes a buffer and returns a boolean.

And please, also add to the docstring that the CONDITIONS are tried one
after another until one is fulfilled, and that all other entries are
ignored, or something like that.  Just for completeness.


Thanks,

Michael.





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

* bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented
  2012-11-10 19:18 bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented Michael Heerdegen
  2012-11-10 19:42 ` Michael Heerdegen
@ 2012-11-13 13:50 ` martin rudalics
  2012-11-16 15:32 ` martin rudalics
  2 siblings, 0 replies; 7+ messages in thread
From: martin rudalics @ 2012-11-13 13:50 UTC (permalink / raw)
  To: michael_heerdegen; +Cc: 12854

 > (defun display-buffer-assq-regexp (buffer-name alist)
 >   "Retrieve ALIST entry corresponding to BUFFER-NAME."
 >   (catch 'match
 >     (dolist (entry alist)
 >       (let ((key (car entry)))
 > 	(when (or (and (stringp key)
 > 		       (string-match-p key buffer-name))
 > 		  (and (symbolp key) (functionp key)
 > 		       (funcall key buffer-name alist)))
 > 	  (throw 'match (cdr entry)))))))
 >
 >
 > Obviously, two things are wrong here:
 >
 > (1) If CONDITION is a function, it currently must be a symbol.  I don't
 > see why lambda expressions should be forbidden.  The user should not
 > need to use defun only to be able specify an argument.

I see no problems with removing the (symbolp key) check.

 > (2) If CONDITION is a function, it takes _two_ arguments: a buffer
 > _name_ (not a buffer) _and_ an alist.  That should be clarified in the
 > docstring.

IIUC the correct solution is to not pass ALIST to the function specified
by `key'.

martin





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

* bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented
  2012-11-10 19:18 bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented Michael Heerdegen
  2012-11-10 19:42 ` Michael Heerdegen
  2012-11-13 13:50 ` martin rudalics
@ 2012-11-16 15:32 ` martin rudalics
  2012-11-18  1:00   ` Michael Heerdegen
  2 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2012-11-16 15:32 UTC (permalink / raw)
  To: 12854-done; +Cc: michael_heerdegen

 > Obviously, two things are wrong here:
 >
 > (1) If CONDITION is a function, it currently must be a symbol.  I don't
 > see why lambda expressions should be forbidden.  The user should not
 > need to use defun only to be able specify an argument.

I lifted this restriction in revision 110885 on the Emacs-24 release
branch.

 > (2) If CONDITION is a function, it takes _two_ arguments: a buffer
 > _name_ (not a buffer) _and_ an alist.  That should be clarified in the
 > docstring.

As a matter of fact, the code called that function with the variable
`display-buffer-alist' as second argument which doesn't make any sense.
I now pass it the ACTION argument of `display-buffer' instead and tried
to document this in the same revision as above.

Thanks, martin





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

* bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented
  2012-11-10 19:42 ` Michael Heerdegen
@ 2012-11-16 15:33   ` martin rudalics
  2012-11-18  1:02     ` Michael Heerdegen
  0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2012-11-16 15:33 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 12854

 > And please, also add to the docstring that the CONDITIONS are tried one
 > after another until one is fulfilled, and that all other entries are
 > ignored, or something like that.  Just for completeness.

Hmm...  I tried to do that in revision 110885.  Please have a look.

Thanks again, martin





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

* bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented
  2012-11-16 15:32 ` martin rudalics
@ 2012-11-18  1:00   ` Michael Heerdegen
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Heerdegen @ 2012-11-18  1:00 UTC (permalink / raw)
  To: 12854

martin rudalics <rudalics@gmx.at> writes:

> > (1) If CONDITION is a function, it currently must be a symbol.  I don't
> > see why lambda expressions should be forbidden.  The user should not
> > need to use defun only to be able specify an argument.
>
> I lifted this restriction in revision 110885 on the Emacs-24 release
> branch.

Ok, thanks.  My stuff works now as it's supposed to.

> > (2) If CONDITION is a function, it takes _two_ arguments: a buffer
> > _name_ (not a buffer) _and_ an alist.  That should be clarified in the
> > docstring.
>
> As a matter of fact, the code called that function with the variable
> `display-buffer-alist' as second argument which doesn't make any sense.
> I now pass it the ACTION argument of `display-buffer' instead and tried
> to document this in the same revision as above.

Looks ok to me, the code as well as the doc.


Thanks,

Michael.





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

* bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented
  2012-11-16 15:33   ` martin rudalics
@ 2012-11-18  1:02     ` Michael Heerdegen
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Heerdegen @ 2012-11-18  1:02 UTC (permalink / raw)
  To: martin rudalics; +Cc: 12854

martin rudalics <rudalics@gmx.at> writes:

> > And please, also add to the docstring that the CONDITIONS are tried one
> > after another until one is fulfilled, and that all other entries are
> > ignored, or something like that.  Just for completeness.
>
> Hmm...  I tried to do that in revision 110885.  Please have a look.

Looks also ok to me, thanks!


Regards,

Michael.





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

end of thread, other threads:[~2012-11-18  1:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-10 19:18 bug#12854: 24.2.50; `display-buffer-alist': conditions are not handled as documented Michael Heerdegen
2012-11-10 19:42 ` Michael Heerdegen
2012-11-16 15:33   ` martin rudalics
2012-11-18  1:02     ` Michael Heerdegen
2012-11-13 13:50 ` martin rudalics
2012-11-16 15:32 ` martin rudalics
2012-11-18  1:00   ` Michael Heerdegen

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