unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Combine 2 commands in a toggle-function
@ 2012-10-13  9:06 Martin Butz
  2012-10-13  9:19 ` Peter Dyballa
  2012-10-13  9:54 ` Martin Butz
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Butz @ 2012-10-13  9:06 UTC (permalink / raw)
  To: help-gnu-emacs

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, mb@mkblog.org, 0421 98749324, www.mkblog.org |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Combine 2 commands in a toggle-function
  2012-10-13  9:06 Combine 2 commands in a toggle-function Martin Butz
@ 2012-10-13  9:19 ` Peter Dyballa
  2012-10-13  9:54 ` Martin Butz
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Dyballa @ 2012-10-13  9:19 UTC (permalink / raw)
  To: mb; +Cc: help-gnu-emacs


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."




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Combine 2 commands in a toggle-function
  2012-10-13  9:06 Combine 2 commands in a toggle-function Martin Butz
  2012-10-13  9:19 ` Peter Dyballa
@ 2012-10-13  9:54 ` Martin Butz
  2012-10-13 11:46   ` Andreas Röhler
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Butz @ 2012-10-13  9:54 UTC (permalink / raw)
  To: help-gnu-emacs

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)
>


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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Combine 2 commands in a toggle-function
  2012-10-13  9:54 ` Martin Butz
@ 2012-10-13 11:46   ` Andreas Röhler
  2012-10-13 13:02     ` Martin Butz
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Röhler @ 2012-10-13 11:46 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Combine 2 commands in a toggle-function
  2012-10-13 11:46   ` Andreas Röhler
@ 2012-10-13 13:02     ` Martin Butz
  2012-10-13 13:19       ` Andreas Röhler
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Butz @ 2012-10-13 13:02 UTC (permalink / raw)
  To: help-gnu-emacs

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

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Combine 2 commands in a toggle-function
  2012-10-13 13:02     ` Martin Butz
@ 2012-10-13 13:19       ` Andreas Röhler
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Röhler @ 2012-10-13 13:19 UTC (permalink / raw)
  To: help-gnu-emacs

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-orgmode@gnu.org

will figure it out for the moment.

Good luck,

Andreas




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-10-13 13:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-13  9:06 Combine 2 commands in a toggle-function Martin Butz
2012-10-13  9:19 ` Peter Dyballa
2012-10-13  9:54 ` Martin Butz
2012-10-13 11:46   ` Andreas Röhler
2012-10-13 13:02     ` Martin Butz
2012-10-13 13:19       ` Andreas Röhler

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).