help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to invoke 'server-visit-files' function from emacsclient -e ?


From: Jason Vas Dias
Subject: how to invoke 'server-visit-files' function from emacsclient -e ?
Date: Wed, 12 Oct 2016 15:34:17 +0100

Good day -

I am trying to write a shell script that will accept a list of ( file
name, line number ) pairs
and get the user's running emacs process to visit each file, scroll to
the line number, and
wait for the user to press 'C-x+#' (invoke the 'server-edit' function)
before allowing
the next file to be visited .

Since emacsclient does most of this (except scrolling to the line number,
a very important feature for this application) ,  I am attempting to
use its '-e'
option to get it to request the running emacs to invoke the 'server-visit-files'
function , which happily accepts a (line #, column#) pair to move the cursor to.

I can get it to do most of this, but am having no luck convincing emacs that
the server-visit-files function's second PROC argument is a process -
just passing the
process ID does not work:

$ ( set -x;  # must use exec here so emaclient's pid is $BASHPID
     exec emacsclient -e \
     '(server-visit-files (assoc "'${PWD}'/a_file" '"'"'(124 0))
['"$BASHPID"' ] )'
   )
+ exec emacsclient -e '(server-visit-files (assoc "/tmp/a_file"
'\''(124 0)) [ 21027 ] )'
*ERROR*: Wrong type argument: processp, [21027]

(same thing happens if the PROC argument is not a vector, or if quoted).

There seems to be no way of specifying an external process , not run by emacs,
as being a LISP object for which the 'processp' "C" function will
return 't' - is this
the case ?

There also seems to be no way of getting emacsclient to load a file in
the users
running emacs and scroll to a given line number:
   $ emacsclient /tmp/a_file -e '(goto-line 124)'
   *ERROR*: Symbol's value as variable is void: /tmp/a_file
It seems the '-e' argument causes emacsclient to assume every argument
(including
arguments preceding the '-e') are lisp expressions.

Is there any way of constructing an emacs LISP 'PROC' object  given an
arbitrary PID
of a process not initiated by emacs ?

Can anyone suggest a way of acheiving the desired result:
   - loading one of many files into a running emacs , causing emacs to
scroll to a given line number
     in that file, and then waiting for user to press 'C-x #' before
allowing the next file to be loaded ?

If not, please consider modifyinh emacsclient to accept a new 'line
number to scroll to' option.

Any  responses gratefully received.
Thanks, Jason



reply via email to

[Prev in Thread] Current Thread [Next in Thread]