* Advice Required
@ 2014-10-27 9:56 Gian Uberto Lauri
2014-10-27 12:45 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Gian Uberto Lauri @ 2014-10-27 9:56 UTC (permalink / raw)
To: help-gnu-emacs
Hello everybody!
I would like to store a ediff-session specific value somewhere, this
value come s to the ediff session via a wrapping function that is
called with emacsclient --eval.
I thought to make the variable buffer specific on the ediff control
panel buffer. Is it a good solution ?
Thank you in advance for your suggestions.
For those curious about what I am doing:
I set up a couple of scripts that let me use Emacs to solve conflicts
with SVN with the use of the --eval option of emacsclient.
After finding some guys suggesting ediff-merge-files-with-ancestor
(but apparently failing to overcoming the non blocking behaviour of
the function) I wrote a first set of shell scripts that used a named
pipe to attain the desired blocking behaviour. The key is advice
ediff-quit so that a shell command is invoked to put a character in
the pipe, thus un-blocking a pending read (all shell commands).
It works this way:
- the calling script launches ediff and then attempts to read from a
named pipe and blocks until input is available
- the advice after ediff-quit sends a character to the named pipe and
un-blocks the read operation
The next step was to write a couple of command around a semaphore, and
this would change nothing - except showing myself how fast I could be
in writing these code snippets.
What I really want is the ability of run several blocking diff at the
same time. One way to differentiate the various instance is the id of
the process used to block the script that launched the emacs diff
function.
I would like to get this architecture:
- the calling scripts spawns a command in the background, does the
ediff launching emacsclient invocation and then waits on the command
in background. Such a command creates a named semaphore whose name
depends on the user and its process IDs and waits on that semaphore.
The semaphore-creating-pid is available to the calling script (the
$! variable) and is used as a parameter of a suitable wrapper
function for ediff or ediff-merge-files-with-ancestor.
This pid will be passed to the signaling program so that the
semaphore name can be computed.
- the signaling program computes the semaphore name and signals it
unblocking the semaphore-creating process and the script that
is waiting after launching it.
--
/\ ___ Ubuntu: ancient
/___/\_|_|\_|__|___Gian Uberto Lauri_____ African word
//--\| | \| | Integralista GNUslamico meaning "I can
\/ coltivatore diretto di software not install
già sistemista a tempo (altrui) perso... Debian"
Warning: gnome-config-daemon considered more dangerous than GOTO
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Advice Required
2014-10-27 9:56 Advice Required Gian Uberto Lauri
@ 2014-10-27 12:45 ` Stefan Monnier
2014-10-27 13:25 ` Gian Uberto Lauri
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2014-10-27 12:45 UTC (permalink / raw)
To: help-gnu-emacs
> - the calling script launches ediff and then attempts to read from a
> named pipe and blocks until input is available
> - the advice after ediff-quit sends a character to the named pipe and
> un-blocks the read operation
You might get the same result more simply by doing something like
emacsclient --eval '(progn (ediff-merge-files-with-ancestor ...) (recursive-edit))'
Then emacsclient will only return when you exit the recursive edit
(i.e. when something runs (throw 'exit <value>) which you could add to
ediff's exit hook).
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Advice Required
2014-10-27 12:45 ` Stefan Monnier
@ 2014-10-27 13:25 ` Gian Uberto Lauri
2014-10-27 13:54 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Gian Uberto Lauri @ 2014-10-27 13:25 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Stefan Monnier writes:
> You might get the same result more simply by doing something like
>
> emacsclient --eval '(progn (ediff-merge-files-with-ancestor ...) (recursive-edit))'
Wonderful. This does not require an external device and the error
message in the minibuffer that you get when you run the command from
within emacs is negligible.
> Then emacsclient will only return when you exit the recursive edit
> (i.e. when something runs (throw 'exit <value>) which you could add to
> ediff's exit hook).
It took me a bit to find how to add it correctly to the hook list, but
it is what I needed.
Anyway, I still have a doubt.
I managed to have this piece of code work
(defun ediff-after (foobar)
(interactive)
(error "pingpipe"))
(advice-add 'ediff-quit :after #'ediff-after)
but when I tried this a second time it did not work, complaining about
wrong number of arguments. What did I wrong?
Thanks in advance!
--
/\ ___ Ubuntu: ancient
/___/\_|_|\_|__|___Gian Uberto Lauri_____ African word
//--\| | \| | Integralista GNUslamico meaning "I can
\/ coltivatore diretto di software not install
già sistemista a tempo (altrui) perso... Debian"
Warning: gnome-config-daemon considered more dangerous than GOTO
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Advice Required
2014-10-27 13:25 ` Gian Uberto Lauri
@ 2014-10-27 13:54 ` Stefan Monnier
2014-10-27 14:11 ` Gian Uberto Lauri
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2014-10-27 13:54 UTC (permalink / raw)
To: help-gnu-emacs
> Wonderful. This does not require an external device and the error
> message in the minibuffer that you get when you run the command from
> within emacs is negligible.
I don't know what error message you're referring to.
> (defun ediff-after (foobar)
> (interactive)
> (error "pingpipe"))
> (advice-add 'ediff-quit :after #'ediff-after)
> but when I tried this a second time it did not work, complaining about
> wrong number of arguments. What did I wrong?
I don't know. Can you show us the backtrace?
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Advice Required
2014-10-27 13:54 ` Stefan Monnier
@ 2014-10-27 14:11 ` Gian Uberto Lauri
2014-10-27 15:03 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Gian Uberto Lauri @ 2014-10-27 14:11 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Stefan Monnier writes:
> > Wonderful. This does not require an external device and the error
> > message in the minibuffer that you get when you run the command from
> > within emacs is negligible.
>
> I don't know what error message you're referring to.
No catch for tag: exit, 1
;; I have (trow 'exit 1) in the hook
> > (defun ediff-after (foobar)
> > (interactive)
> > (error "pingpipe"))
> > (advice-add 'ediff-quit :after #'ediff-after)
>
> > but when I tried this a second time it did not work, complaining about
> > wrong number of arguments. What did I wrong?
>
> I don't know. Can you show us the backtrace?
Debugger stack:
Debugger entered--Lisp error: (wrong-number-of-arguments #[(reverse-default-keep-variants) "\306\x18\307\b!\206\f\0\310\311 \")\210p\312 \313\x1a^[\x1c\314\315\316\r\203.\0\317\r!\203.\0\320\317\r!!\203.\0\321\202/\0\322\"!\203B\0\323\322!\210\fq\210\324\x0e\x17!\202M\0\325\v!\210\326\v!\210\323\322!+\207" [meta-buf-p this-command minibuffer-auto-raise ctl-frm ctl-buf ediff-meta-buffer nil ediff-in-control-buffer-p error "%S: This command runs in Ediff Control Buffer only!" selected-frame t y-or-n-p format "Quit this Ediff session%s? " get-buffer buffer-name " & show containing session group" "" message ediff-really-quit select-frame raise-frame reverse-default-keep-variants] 6 ("/usr/local/share/emacs/24.4/lisp/vc/ediff-util.elc" . 64550) "P"] 0)
#[(reverse-default-keep-variants) "\306\x18\307\b!\206\f\0\310\311 \")\210p\312 \313\x1a^[\x1c\314\315\316\r\203.\0\317\r!\203.\0\320\317\r!!\203.\0\321\202/\0\322\"!\203B\0\323\322!\210\fq\210\324\x0e\x17!\202M\0\325\v!\210\326\v!\210\323\322!+\207" [meta-buf-p this-command minibuffer-auto-raise ctl-frm ctl-buf ediff-meta-buffer nil ediff-in-control-buffer-p error "%S: This command runs in Ediff Control Buffer only!" selected-frame t y-or-n-p format "Quit this Ediff session%s? " get-buffer buffer-name " & show containing session group" "" message ediff-really-quit select-frame raise-frame reverse-default-keep-variants] 6 ("/usr/local/share/emacs/24.4/lisp/vc/ediff-util.elc" . 64550) "P"]()
apply(#[(reverse-default-keep-variants) "\306\x18\307\b!\206\f\0\310\311 \")\210p\312 \313\x1a^[\x1c\314\315\316\r\203.\0\317\r!\203.\0\320\317\r!!\203.\0\321\202/\0\322\"!\203B\0\323\322!\210\fq\210\324\x0e\x17!\202M\0\325\v!\210\326\v!\210\323\322!+\207" [meta-buf-p this-command minibuffer-auto-raise ctl-frm ctl-buf ediff-meta-buffer nil ediff-in-control-buffer-p error "%S: This command runs in Ediff Control Buffer only!" selected-frame t y-or-n-p format "Quit this Ediff session%s? " get-buffer buffer-name " & show containing session group" "" message ediff-really-quit select-frame raise-frame reverse-default-keep-variants] 6 ("/usr/local/share/emacs/24.4/lisp/vc/ediff-util.elc" . 64550) "P"] nil)
ediff-quit()
call-interactively(ediff-quit nil nil)
command-execute(ediff-quit)
Error message
Wrong number of arguments: #[(reverse-default-keep-variants) "Æ\x18Ç\b!\f\0ÈÉ \")pÊ Ë\x1a^[\x1cÌÍÎ\r.\0Ï\r!.\0ÐÏ\r!!.\0Ñ/\0Ò\"!B\0ÓÒ!\fqÔ\x0e\x17!M\0Õ\v!Ö\v!ÓÒ!+" [meta-buf-p this-command minibuffer-auto-raise ctl-frm ctl-buf ediff-meta-buffer nil ediff-in-control-buffer-p error "%S: This command runs in Ediff Control Buffer only!" ...] 6 ("/usr/local/share/emacs/24.4/lisp/vc/ediff-util.elc" . 64550) "P"], 0
Mark set
Removing the advices restores the correct behaviour.
--
/\ ___ Ubuntu: ancient
/___/\_|_|\_|__|___Gian Uberto Lauri_____ African word
//--\| | \| | Integralista GNUslamico meaning "I can
\/ coltivatore diretto di software not install
già sistemista a tempo (altrui) perso... Debian"
Warning: gnome-config-daemon considered more dangerous than GOTO
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-27 15:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-27 9:56 Advice Required Gian Uberto Lauri
2014-10-27 12:45 ` Stefan Monnier
2014-10-27 13:25 ` Gian Uberto Lauri
2014-10-27 13:54 ` Stefan Monnier
2014-10-27 14:11 ` Gian Uberto Lauri
2014-10-27 15:03 ` Stefan Monnier
2014-10-27 15:11 ` Gian Uberto Lauri
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).