all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* special-display-regexps
@ 2007-04-27  2:20 Tyler Smith
  2007-04-27  4:49 ` special-display-regexps Drew Adams
  0 siblings, 1 reply; 9+ messages in thread
From: Tyler Smith @ 2007-04-27  2:20 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I'm trying to set up special display frames. I want to use if for the
following buffers:

*Completions*
*Help*
*help[R](functionname)*

I've tried the following regexps:

(setq special-display-regexps
      '("^\\*Help\\*$"
      "^\\*Completions\\*$"
      "^\\*help\\[R\\]([a-z]*)\\*$"))

This works fine for the first two, but the third doesn't catch. I've
also tried with single \ and double \, as well as simpler things like
"\*help.*" -- this works for regexp searches when I paste the buffer
name into scratch, but they don't work for the special display. What
am I doing wrong?

Thanks,

Tyler

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

* RE: special-display-regexps
  2007-04-27  2:20 special-display-regexps Tyler Smith
@ 2007-04-27  4:49 ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2007-04-27  4:49 UTC (permalink / raw)
  To: help-gnu-emacs

> I'm trying to set up special display frames. I want to use if for the
> following buffers:
>
> *Completions*
> *Help*
> *help[R](functionname)*
>
> I've tried the following regexps:
> (setq special-display-regexps
>       '("^\\*Help\\*$"
>       "^\\*Completions\\*$"
>       "^\\*help\\[R\\]([a-z]*)\\*$"))
>
> This works fine for the first two, but the third doesn't catch. I've
> also tried with single \ and double \, as well as simpler things like
> "\*help.*" -- this works for regexp searches when I paste the buffer
> name into scratch, but they don't work for the special display. What
> am I doing wrong?

"[*]Help[*]" etc. is simpler.

You want the backslash to be in the string itself, so that the * is escaped.
To put a single backslash into a string in Lisp, you need to use \\\\. See
node "Regexp Special" in the Elisp manual.

In case it helps, here's a library that uses special-display for *Help* and
*Completions* (in a different way, however):

Code: http://www.emacswiki.org/cgi-bin/wiki/oneonone.el
Doc: http://www.emacswiki.org/cgi-bin/wiki/Help_and_Completions_Frames

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

* Re: special-display-regexps
       [not found] <mailman.2574.1177649782.7795.help-gnu-emacs@gnu.org>
@ 2007-04-27 12:40 ` Tyler Smith
  2007-04-27 15:06   ` special-display-regexps Drew Adams
  0 siblings, 1 reply; 9+ messages in thread
From: Tyler Smith @ 2007-04-27 12:40 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-04-27, Drew Adams <drew.adams@oracle.com> wrote:
>> I'm trying to set up special display frames. I want to use if for the
>> following buffers:
>>
>> *Completions*
>> *Help*
>> *help[R](functionname)*
>>
>> I've tried the following regexps:
>> (setq special-display-regexps
>>       '("^\\*Help\\*$"
>>       "^\\*Completions\\*$"
>>       "^\\*help\\[R\\]([a-z]*)\\*$"))
>>
>> This works fine for the first two, but the third doesn't catch. I've
>> also tried with single \ and double \, as well as simpler things like
>> "\*help.*" -- this works for regexp searches when I paste the buffer
>> name into scratch, but they don't work for the special display. What
>> am I doing wrong?
>
> "[*]Help[*]" etc. is simpler.
>
> You want the backslash to be in the string itself, so that the * is escaped.
> To put a single backslash into a string in Lisp, you need to use \\\\. See
> node "Regexp Special" in the Elisp manual.
>

This is really confusing now.

 "^\\*Completions\\*$" matches *Completions*, although I'm not sure
 why since it is actually the regexp ^*Completions*$, since the double
 \ should get filtered out by the string reader??

and "^[*]help.*" still doesn't match *help[R](help-topic)* , but the
same thing entered in a regexp search will match.

Any other advice?

Thanks,

Tyler

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

* RE: special-display-regexps
  2007-04-27 12:40 ` special-display-regexps Tyler Smith
@ 2007-04-27 15:06   ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2007-04-27 15:06 UTC (permalink / raw)
  To: Tyler Smith, help-gnu-emacs

> >> I'm trying to set up special display frames. I want to use if for the
> >> following buffers:
> >>
> >> *Completions*
> >> *Help*
> >> *help[R](functionname)*
> >>
> >> I've tried the following regexps:
> >> (setq special-display-regexps
> >>       '("^\\*Help\\*$"
> >>       "^\\*Completions\\*$"
> >>       "^\\*help\\[R\\]([a-z]*)\\*$"))
> >>
> >> This works fine for the first two, but the third doesn't catch. I've
> >> also tried with single \ and double \, as well as simpler things like
> >> "\*help.*" -- this works for regexp searches when I paste the buffer
> >> name into scratch, but they don't work for the special display. What
> >> am I doing wrong?
> >
> > "[*]Help[*]" etc. is simpler.
> >
> > You want the backslash to be in the string itself, so that the
> > * is escaped.
> > To put a single backslash into a string in Lisp, you need to
> > use \\\\. See node "Regexp Special" in the Elisp manual.
>
> This is really confusing now.
>
>  \\\\*$" matches *Completions*, although I'm not sure
>  why since it is actually the regexp ^*Completions*$, since the double
>  \ should get filtered out by the string reader??

My bad. \\* escapes the `*' OK. You need \\\\ only if you want to escape a
`\', that is, to have a `\' in the string. Here, you just want to escape the
`*'.

> and "^[*]help.*" still doesn't match *help[R](help-topic)* , but the
> same thing entered in a regexp search will match.

The problem with your original code was only this: You have [a-z]*, when you
need [-a-z]*. In your example, you have "(help-topic)", which includes the
character `-', which is not a lowercase letter.

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

* Re: special-display-regexps
       [not found] <mailman.2605.1177686747.7795.help-gnu-emacs@gnu.org>
@ 2007-04-27 15:29 ` Tyler Smith
  2007-04-27 16:00   ` special-display-regexps Drew Adams
  0 siblings, 1 reply; 9+ messages in thread
From: Tyler Smith @ 2007-04-27 15:29 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-04-27, Drew Adams <drew.adams@oracle.com> wrote:
>
>> and "^[*]help.*" still doesn't match *help[R](help-topic)* , but the
>> same thing entered in a regexp search will match.
>
> The problem with your original code was only this: You have [a-z]*, when you
> need [-a-z]*. In your example, you have "(help-topic)", which includes the
> character `-', which is not a lowercase letter.
>

Ok, but what about the code here: "^[*]help.*" - that should match
anything that starts with *help, followed by one or more of any
character, no? That should cover any possible configuration of
*help[R](<anything>)* ? It works in regexp searches within a buffer,
just not for a buffer name. I checked the value returned by
(buffer-name), so I'm pretty sure I'm trying to match the right
phrase. 

In actual practice there isn't a hyphen inside the round brackets very
often (ever?), and not in any of my test cases, which include things
like:

*help[R](matrix)*
*help[R](nrow)*
*help[R](list)*

Thanks for your help!

Tyler

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

* RE: special-display-regexps
  2007-04-27 15:29 ` special-display-regexps Tyler Smith
@ 2007-04-27 16:00   ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2007-04-27 16:00 UTC (permalink / raw)
  To: Tyler Smith, help-gnu-emacs

> >> and "^[*]help.*" still doesn't match *help[R](help-topic)* , but the
> >> same thing entered in a regexp search will match.
> >
> > The problem with your original code was only this: You have
> > [a-z]*, when you need [-a-z]*. In your example, you have
> > "(help-topic)", which includes the
> > character `-', which is not a lowercase letter.
>
> Ok, but what about the code here: "^[*]help.*" - that should match
> anything that starts with *help, followed by one or more of any
> character, no?

Zero or more characters except newline.

> That should cover any possible configuration of
> *help[R](<anything>)* ?

Yes.

> It works in regexp searches within a buffer,
> just not for a buffer name. I checked the value returned by
> (buffer-name), so I'm pretty sure I'm trying to match the right
> phrase.

Are you sure you're testing with `pop-to-buffer' or `display-buffer' (or
something that calls one of those)? It works for me, using your examples.

You can also test using `special-display-p', but you will need to ensure
that `same-window-buffer-names' and `same-window-regexps' are not
interfering with whatever you use for `special-display-buffer-regexps'.

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

* Re: special-display-regexps
       [not found] <mailman.2609.1177690056.7795.help-gnu-emacs@gnu.org>
@ 2007-04-27 16:53 ` Tyler Smith
  2007-04-27 17:43   ` special-display-regexps Drew Adams
  0 siblings, 1 reply; 9+ messages in thread
From: Tyler Smith @ 2007-04-27 16:53 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-04-27, Drew Adams <drew.adams@oracle.com> wrote:
>
>> That should cover any possible configuration of
>> *help[R](<anything>)* ?
>
> Yes.
>
>> It works in regexp searches within a buffer,
>> just not for a buffer name. I checked the value returned by
>> (buffer-name), so I'm pretty sure I'm trying to match the right
>> phrase.
>
> Are you sure you're testing with `pop-to-buffer' or `display-buffer' (or
> something that calls one of those)? It works for me, using your examples.
>
> You can also test using `special-display-p', but you will need to ensure
> that `same-window-buffer-names' and `same-window-regexps' are not
> interfering with whatever you use for `special-display-buffer-regexps'.
>

I don't know how to use pop-to-buffer or display-buffer to test
this. I tried special-display-p on the following, and all worked as
expected. 

(special-display-p "*Completions*") ; returns t
(special-display-p "*Help*") ; returns t
(special-display-p "*help[R](matrix)*") ; returns t
(special-display-p "*scratch*") ; returns nil

Maybe it's something internal to ESS -- it uses a special function to
call the help buffer, so I've posted my problem on the
gmane.emacs.ess.general list to see if they know what's going on. 

Thanks again,

Tyler

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

* RE: special-display-regexps
  2007-04-27 16:53 ` special-display-regexps Tyler Smith
@ 2007-04-27 17:43   ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2007-04-27 17:43 UTC (permalink / raw)
  To: Tyler Smith, help-gnu-emacs

> > Are you sure you're testing with `pop-to-buffer' or `display-buffer' (or
> > something that calls one of those)? It works for me, using your 
> > examples.
>
> I don't know how to use pop-to-buffer or display-buffer to test
> this. 

M-: (pop-to-buffer "*help[R](matrix)*")

> I tried special-display-p on the following, and all worked as
> expected. (special-display-p "*help[R](matrix)*") ; returns t
>
> Maybe it's something internal to ESS -- it uses a special function to
> call the help buffer, so I've posted my problem on the
> gmane.emacs.ess.general list to see if they know what's going on.

That sounds like a good idea.

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

* Re: special-display-regexps
       [not found] <mailman.2610.1177696237.7795.help-gnu-emacs@gnu.org>
@ 2007-04-27 19:43 ` Tyler Smith
  0 siblings, 0 replies; 9+ messages in thread
From: Tyler Smith @ 2007-04-27 19:43 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-04-27, Drew Adams <drew.adams@oracle.com> wrote:
>>
>> Maybe it's something internal to ESS -- it uses a special function to
>> call the help buffer, so I've posted my problem on the
>> gmane.emacs.ess.general list to see if they know what's going on.
>
> That sounds like a good idea.
>

Ok, I'm still not sure why my regexps weren't working, but ESS
provides it's own way to manipulate special buffer frames. The fact
that these customizations are available suggests that the usual
special buffer frames approach doesn't work with ESS.  The
following lines in my .emacs achieve what I need, in case anyone else
stumbles upon this thread looking for answers:

(setq ess-help-own-frame t)

(setq ess-help-frame-alist '((user-position . t)
				    (top . (- 45))
				    (left . (- 0))
				    (width . 70)
				    (height . 14)
				    (unsplittable . t)))

The user-position and unsplittable variables may not be necessary...

Thanks again,

Tyler

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

end of thread, other threads:[~2007-04-27 19:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2605.1177686747.7795.help-gnu-emacs@gnu.org>
2007-04-27 15:29 ` special-display-regexps Tyler Smith
2007-04-27 16:00   ` special-display-regexps Drew Adams
     [not found] <mailman.2610.1177696237.7795.help-gnu-emacs@gnu.org>
2007-04-27 19:43 ` special-display-regexps Tyler Smith
     [not found] <mailman.2609.1177690056.7795.help-gnu-emacs@gnu.org>
2007-04-27 16:53 ` special-display-regexps Tyler Smith
2007-04-27 17:43   ` special-display-regexps Drew Adams
     [not found] <mailman.2574.1177649782.7795.help-gnu-emacs@gnu.org>
2007-04-27 12:40 ` special-display-regexps Tyler Smith
2007-04-27 15:06   ` special-display-regexps Drew Adams
2007-04-27  2:20 special-display-regexps Tyler Smith
2007-04-27  4:49 ` special-display-regexps Drew Adams

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.