unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* customize xref
@ 2017-01-10 18:28 James K. Lowden
  2017-01-10 20:38 ` James K. Lowden
  0 siblings, 1 reply; 4+ messages in thread
From: James K. Lowden @ 2017-01-10 18:28 UTC (permalink / raw)
  To: help-gnu-emacs

I have an elisp syntax question.  

I'd like to customize xref such that, when I jump to a definition, it
puts the line it finds at the top of the window.  "customize group" led
me to xref-after-jump-hook, which calls recenter, and recenter takes an
optional argument that, if provided, is the line to "recenter" on.
Indeed, if I use "C-u 0 M-x recenter", it puts the line the cursor is
on at the top of the window.  

By passing "xref" to customize-group, I was able to see roughly what to
do.  In my .emacs I now see this (other settings elided): 

(custom-set-variables
 '(xref-after-jump-hook
   (quote (recenter xref-pulse-momentarily))))

How to sneak an argument in there?  I tried this: 

(custom-set-variables
 '(xref-after-jump-hook
   (quote ((recenter 0) xref-pulse-momentarily))))

but that only produces the error:

	run-hooks: Invalid function: (recenter 0)

I know I'm in the vicinity of quoting, but I'm not sure how to see
around the corner.  Help?  

--jkl


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

* Re: customize xref
  2017-01-10 18:28 customize xref James K. Lowden
@ 2017-01-10 20:38 ` James K. Lowden
  2017-01-11  0:42   ` Dmitry Gutov
  2017-01-11  9:03   ` Ralf Fassel
  0 siblings, 2 replies; 4+ messages in thread
From: James K. Lowden @ 2017-01-10 20:38 UTC (permalink / raw)
  To: help-gnu-emacs

On Tue, 10 Jan 2017 13:28:08 -0500
"James K. Lowden" <jklowden@speakeasy.net> wrote:

> (custom-set-variables
>  '(xref-after-jump-hook
>    (quote (recenter xref-pulse-momentarily))))

I see: 

(custom-set-variables
 '(xref-after-jump-hook
   (quote (lambda () (recenter 0) xref-pulse-momentarily))))

Because recenter is a function, it needs to be replaced with a
function, not a function invocation, and not the output of a function.
Unless, that is -- as in the case of lambda -- the function returns a
function.  

In this case, xref-after-jump-hook takes as parameters two arguments,
each a function.  I can't pass it 3 arguments

	(recenter 0 xref-pulse-momentarily)

nor the result of recentering, 

	((recenter 0) xref-pulse-momentarily)

but I can pass it an unnamed function.  The lisp interpreter reduces 

   (quote (lambda () (recenter 0) xref-pulse-momentarily))

by executing the lambda to 

   (quote (anonymous-func xref-pulse-momentarily))

where anonymous-func calls (recenter 0).

--jkl


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

* Re: customize xref
  2017-01-10 20:38 ` James K. Lowden
@ 2017-01-11  0:42   ` Dmitry Gutov
  2017-01-11  9:03   ` Ralf Fassel
  1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Gutov @ 2017-01-11  0:42 UTC (permalink / raw)
  To: James K. Lowden, help-gnu-emacs

On 10.01.2017 23:38, James K. Lowden wrote:

>    (quote (lambda () (recenter 0) xref-pulse-momentarily))

You're close, but it should look like this:

(quote ((lambda () (recenter 0)) xref-pulse-momentarily))



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

* Re: customize xref
  2017-01-10 20:38 ` James K. Lowden
  2017-01-11  0:42   ` Dmitry Gutov
@ 2017-01-11  9:03   ` Ralf Fassel
  1 sibling, 0 replies; 4+ messages in thread
From: Ralf Fassel @ 2017-01-11  9:03 UTC (permalink / raw)
  To: help-gnu-emacs

* "James K. Lowden" <jklowden@speakeasy.net>
| > (custom-set-variables
| >  '(xref-after-jump-hook
| >    (quote (recenter xref-pulse-momentarily))))
>
| I see: 
>
| (custom-set-variables
|  '(xref-after-jump-hook
|    (quote (lambda () (recenter 0) xref-pulse-momentarily))))

What is the 'xref-pulse-momentarily' good for?
From my understanding of elisp, you should be good with

| > (custom-set-variables
| >  '(xref-after-jump-hook
| >    (quote (recenter 0))))

HTH
R'


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

end of thread, other threads:[~2017-01-11  9:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-10 18:28 customize xref James K. Lowden
2017-01-10 20:38 ` James K. Lowden
2017-01-11  0:42   ` Dmitry Gutov
2017-01-11  9:03   ` Ralf Fassel

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