Subject: Re: bug#59388: Open emacsclient file at last line

From: Jim Porter <[email-masked]>
Date: Sun, 20 Nov 2022 10:49:10 -0800

On 11/19/2022 11:22 PM, Eli Zaretskii wrote:
>> Date: Sat, 19 Nov 2022 15:06:14 -0800
>> Cc: [email-masked], [email-masked], [email-masked]
>> From: Jim Porter <[email-masked]>
>>
>> On 11/19/2022 12:33 PM, Eli Zaretskii wrote:
>>> Maybe we don't need to go as far as that discussion led us?  Just adding a
>>> switch --funcall, to mimic what Emacs has, could be enough?  Then we'd be
>>> able to say
>>>
>>>     emacsclient -f eob FILE
>>>
>>> (assuming we also add a function 'eob' to Emacs).
>>
>> With the caveat that -f is already used for --server-file, I think this
>> would be fine. --funcall is a lot simpler to implement than --apply, at
>> least from emacsclient.
> 
> Then I think I'm okay with adding --funcall to emacsclient, as a solution
> for this feature request.  With the proviso that the named function will be
> called _after_ visiting the named FILE, right?

Assuming it's possible, I think the most flexible, obvious, and 
consistent[1] way for it to work would be to obey the order of the 
arguments. So "emacsclient --funcall func file.txt" calls func and then 
visits file.txt, whereas "emacsclient file.txt --funcall func" visits 
file.txt and then calls func.

The downside of this is that it's a little bit trickier to write an 
alias for the case in this bug. 'alias edit-end="emacsclient --funcall 
end-of-buffer"' wouldn't do the right thing.

I don't think that's a problem though, since the original proposal had 
the same limitation: the "+" comes after the file, as in "emacsclient 
file.txt +". So my suggestion above would work just like the original 
proposal except that "+" is spelled differently.

[1] This is how --funcall works with the regular emacs executable, as 
far as I can tell.