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

Combine 2 commands in a toggle-function

7 views
Skip to first unread message

Martin Butz

unread,
Oct 13, 2012, 5:06:11 AM10/13/12
to help-gn...@gnu.org
Hi,

as my lisp-knowledge is less than basic (up to now), I wonder if someone
can help:

I would like to create a toggle function binded to a key and combining
two commands, such as:

'escreen-menu [1]
'kill-buffer-other-window

Martin

[1] I quite like escreen, but calling the menu leaves me with a new
frame an a buffer, which I only need temporarily for reference. I do not
know an escreen function, which does close the menu (such as /q/ closing
the agenda in org-mode)

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| G. Martin Butz, m...@mkblog.org, 0421 98749324, www.mkblog.org |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Peter Dyballa

unread,
Oct 13, 2012, 5:19:54 AM10/13/12
to m...@mkblog.org, help-gn...@gnu.org

Am 13.10.2012 um 11:06 schrieb Martin Butz:

> I would like to create a toggle function binded to a key and combining two commands, such as:

Write down the function in your init file, bind it to some key in your init file!

--
Greetings

Pete

"A TRUE Klingon warrior does not comment his code."


Martin Butz

unread,
Oct 13, 2012, 5:54:04 AM10/13/12
to help-gn...@gnu.org
Pete,

thanks. So far I know what to do. What I do not now is, how to combine
the two commands in one function, in order to toggle them. A hint would
be helpful.

Greetings
Martin

Am 13.10.2012 11:06, schrieb Martin Butz:
> Hi,
>
> as my lisp-knowledge is less than basic (up to now), I wonder if someone
> can help:
>
> I would like to create a toggle function binded to a key and combining
> two commands, such as:
>

Andreas Röhler

unread,
Oct 13, 2012, 7:46:46 AM10/13/12
to help-gn...@gnu.org
Am 13.10.2012 11:54, schrieb Martin Butz:
> Pete,
>
> thanks. So far I know what to do. What I do not now is, how to combine the two commands in one function, in order to toggle them. A hint would be helpful.
>
> Greetings
> Martin
>
> Am 13.10.2012 11:06, schrieb Martin Butz:
>> Hi,
>>
>> as my lisp-knowledge is less than basic (up to now), I wonder if someone
>> can help:
>>
>> I would like to create a toggle function binded to a key and combining
>> two commands, such as:
>>
>> 'escreen-menu [1]
>> 'kill-buffer-other-window
>>
>> Martin
>>
>> [1] I quite like escreen, but calling the menu leaves me with a new
>> frame an a buffer, which I only need temporarily for reference. I do not
>> know an escreen function, which does close the menu (such as /q/ closing
>> the agenda in org-mode)
>>
>
>

maybe like this:

(defvar my-toggled-commands-p nil
"When switched on, commands are run ")

(defun my-commands-toggle ()
(interactive)
(if my-toggled-commands-p
(progn
(setq my-toggled-commands-p nil)
(message "%s" "my-toggled-commands-p switched off"))
(message "%s" "Running my-toggled-commands")
(setq my-toggled-commands-p t)
(funcall 'FIRST)
(funcall 'SECOND)))


WRT the the function called, you might need to figure out the details, which arguments to pass etc.

Andreas

Martin Butz

unread,
Oct 13, 2012, 9:02:53 AM10/13/12
to help-gn...@gnu.org
Hello Andreas,

thanks for the code!

Am 13.10.2012 13:46, schrieb Andreas Röhler:
> (defvar my-toggled-commands-p nil
> "When switched on, commands are run ")
>
> (defun my-commands-toggle ()
> (interactive)
> (if my-toggled-commands-p
> (progn
> (setq my-toggled-commands-p nil)
> (message "%s" "my-toggled-commands-p switched off"))
> (message "%s" "Running my-toggled-commands")
> (setq my-toggled-commands-p t)
> (funcall 'FIRST)
> (funcall 'SECOND)))

> WRT the the function called, you might need to figure out the details, which arguments to pass etc.

Yes. This way 'kill-buffer-other-window does obviously not know, which
frame/buffer to kill. I will have to start learning lisp to stand on my
own feet.

Thanks
Martin

Andreas Röhler

unread,
Oct 13, 2012, 9:19:38 AM10/13/12
to help-gn...@gnu.org
Am 13.10.2012 15:02, schrieb Martin Butz:
> Hello Andreas,
>
> thanks for the code!
>
> Am 13.10.2012 13:46, schrieb Andreas Röhler:
>> (defvar my-toggled-commands-p nil
>> "When switched on, commands are run ")
>>
>> (defun my-commands-toggle ()
>> (interactive)
>> (if my-toggled-commands-p
>> (progn
>> (setq my-toggled-commands-p nil)
>> (message "%s" "my-toggled-commands-p switched off"))
>> (message "%s" "Running my-toggled-commands")
>> (setq my-toggled-commands-p t)
>> (funcall 'FIRST)
>> (funcall 'SECOND)))
>
>> WRT the the function called, you might need to figure out the details, which arguments to pass etc.
>
> Yes. This way 'kill-buffer-other-window does obviously not know, which frame/buffer to kill. I will have to start learning lisp to stand on my own feet.
>
> Thanks
> Martin
>

maybe someone at

emacs-...@gnu.org

will figure it out for the moment.

Good luck,

Andreas


0 new messages