Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

customize xref

12 views
Skip to first unread message

James K. Lowden

unread,
Jan 10, 2017, 1:28:11 PM1/10/17
to
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

James K. Lowden

unread,
Jan 10, 2017, 3:39:01 PM1/10/17
to
On Tue, 10 Jan 2017 13:28:08 -0500
"James K. Lowden" <jklo...@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

Ralf Fassel

unread,
Jan 11, 2017, 4:03:19 AM1/11/17
to
* "James K. Lowden" <jklo...@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'
0 new messages