* Automating function with interactive args
@ 2012-04-26 16:53 BDB
2012-04-26 17:08 ` Tassilo Horn
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: BDB @ 2012-04-26 16:53 UTC (permalink / raw)
To: help-gnu-emacs
Quite often I use "M-x ediff-revision", which then prompts me for the
files to ediff, and I always just accept the defaults by hitting return
to the 3 prompts. I would like to make all of this a single keystroke.
A straight keyboard macro doesn't seem to work with the prompts, and my
other googling hasn't turned up a solution. Ideas?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Automating function with interactive args
2012-04-26 16:53 Automating function with interactive args BDB
@ 2012-04-26 17:08 ` Tassilo Horn
2012-04-26 17:21 ` Drew Adams
[not found] ` <mailman.105.1335460111.855.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 7+ messages in thread
From: Tassilo Horn @ 2012-04-26 17:08 UTC (permalink / raw)
To: help-gnu-emacs
BDB <noemail@yahoo.com> writes:
> Quite often I use "M-x ediff-revision", which then prompts me for the
> files to ediff, and I always just accept the defaults by hitting return
> to the 3 prompts. I would like to make all of this a single keystroke.
> A straight keyboard macro doesn't seem to work with the prompts, and my
> other googling hasn't turned up a solution. Ideas?
I think this command should do the trick.
--8<---------------cut here---------------start------------->8---
(require 'ediff)
(defun my-ediff-revision-latest ()
(interactive)
(ediff-load-version-control)
(funcall
(intern (format "ediff-%S-internal" ediff-version-control-package))
nil nil nil))
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Automating function with interactive args
2012-04-26 16:53 Automating function with interactive args BDB
2012-04-26 17:08 ` Tassilo Horn
@ 2012-04-26 17:21 ` Drew Adams
[not found] ` <mailman.105.1335460111.855.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2012-04-26 17:21 UTC (permalink / raw)
To: 'BDB', help-gnu-emacs
> Quite often I use "M-x ediff-revision", which then prompts me for the
> files to ediff, and I always just accept the defaults by
> hitting return to the 3 prompts. I would like to make all of
> this a single keystroke. A straight keyboard macro doesn't seem
> to work with the prompts, and my other googling hasn't turned up
> a solution. Ideas?
Perhaps something like this (untested)?
(defun my-ediff-revision ()
"..."
(interactive)
(find-file (expand-file-name
(file-name-directory (ediff-get-default-file-name))
(if ediff-use-last-dir
ediff-last-dir-A
default-directory)))
(when (and (buffer-modified-p)
(y-or-n-p (format "Buffer %s is modified. Save buffer? "
(buffer-name))))
(save-buffer (current-buffer)))
(ediff-load-version-control)
(funcall (intern (format "ediff-%S-internal"
ediff-version-control-package))
"" "" nil))
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.105.1335460111.855.help-gnu-emacs@gnu.org>]
* Re: Automating function with interactive args
[not found] ` <mailman.105.1335460111.855.help-gnu-emacs@gnu.org>
@ 2012-04-26 20:35 ` BDB
2012-04-27 7:42 ` Tassilo Horn
[not found] ` <mailman.155.1335512574.855.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: BDB @ 2012-04-26 20:35 UTC (permalink / raw)
To: help-gnu-emacs
Tassilo Horn wrote:
> --8<---------------cut here---------------start------------->8---
> (require 'ediff)
>
> (defun my-ediff-revision-latest ()
> (interactive)
> (ediff-load-version-control)
> (funcall
> (intern (format "ediff-%S-internal" ediff-version-control-package))
> nil nil nil))
> --8<---------------cut here---------------end--------------->8---
This didn't work, however it seemed close (closer than the other example
posted). It brought up ediff with both windows pointing to the same
HEAD version of the file, and gave an error
"Removing old name: no such file or directory ..."
Anyone willing to help me understand the code here? The format command
is kind of like sprintf, right? Why are you trying to call
ediff-<value>-internal? What's that?
Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Automating function with interactive args
2012-04-26 20:35 ` BDB
@ 2012-04-27 7:42 ` Tassilo Horn
[not found] ` <mailman.155.1335512574.855.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Tassilo Horn @ 2012-04-27 7:42 UTC (permalink / raw)
To: help-gnu-emacs
BDB <noemail@yahoo.com> writes:
> Tassilo Horn wrote:
>> --8<---------------cut here---------------start------------->8---
>> (require 'ediff)
>>
>> (defun my-ediff-revision-latest ()
>> (interactive)
>> (ediff-load-version-control)
>> (funcall
>> (intern (format "ediff-%S-internal" ediff-version-control-package))
>> nil nil nil))
>> --8<---------------cut here---------------end--------------->8---
>
> This didn't work, however it seemed close (closer than the other
> example posted). It brought up ediff with both windows pointing to
> the same HEAD version of the file, and gave an error "Removing old
> name: no such file or directory ..."
Hm...
> Anyone willing to help me understand the code here? The format
> command is kind of like sprintf, right?
Yes.
> Why are you trying to call ediff-<value>-internal? What's that?
I basically looked at the implementation of ediff-revision, and in the
end it just calls ediff-<value>-internal where value is usually vc.
I think the problem was that I provided nil for the files but they
should be "" for the defaults. This one seems to work, and I also query
to save the buffer now like Drew.
--8<---------------cut here---------------start------------->8---
(defun my-ediff-revision-latest ()
(interactive)
(if (and (buffer-modified-p)
(y-or-n-p (format "Buffer %s is modified. Save buffer? "
(buffer-name))))
(save-buffer (current-buffer)))
(ediff-load-version-control)
(funcall
(intern (format "ediff-%S-internal" ediff-version-control-package))
"" "" nil))
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.155.1335512574.855.help-gnu-emacs@gnu.org>]
* Re: Automating function with interactive args
[not found] ` <mailman.155.1335512574.855.help-gnu-emacs@gnu.org>
@ 2012-04-27 16:30 ` BDB
2012-04-27 16:43 ` Drew Adams
0 siblings, 1 reply; 7+ messages in thread
From: BDB @ 2012-04-27 16:30 UTC (permalink / raw)
To: help-gnu-emacs
Tassilo Horn wrote:
>
> --8<---------------cut here---------------start------------->8---
> (defun my-ediff-revision-latest ()
> (interactive)
> (if (and (buffer-modified-p)
> (y-or-n-p (format "Buffer %s is modified. Save buffer? "
> (buffer-name))))
> (save-buffer (current-buffer)))
> (ediff-load-version-control)
> (funcall
> (intern (format "ediff-%S-internal" ediff-version-control-package))
> "" "" nil))
> --8<---------------cut here---------------end--------------->8---
Excellent, works perfectly. Thank you!
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Automating function with interactive args
2012-04-27 16:30 ` BDB
@ 2012-04-27 16:43 ` Drew Adams
0 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2012-04-27 16:43 UTC (permalink / raw)
To: 'BDB', help-gnu-emacs
> Excellent, works perfectly. Thank you!
Which is identical to what I sent, BTW, except that I included also the
`find-file' part from `ediff-revision', to respect option `ediff-use-last-dir'.
But you said that didn't work, so probably there was some part of it that was
incorrect. (As I said, "untested.) If you care about that option then you
might want to experiment and tweak it a bit to fix whatever was wrong.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-04-27 16:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-26 16:53 Automating function with interactive args BDB
2012-04-26 17:08 ` Tassilo Horn
2012-04-26 17:21 ` Drew Adams
[not found] ` <mailman.105.1335460111.855.help-gnu-emacs@gnu.org>
2012-04-26 20:35 ` BDB
2012-04-27 7:42 ` Tassilo Horn
[not found] ` <mailman.155.1335512574.855.help-gnu-emacs@gnu.org>
2012-04-27 16:30 ` BDB
2012-04-27 16:43 ` Drew Adams
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.