* Bind C-u C-c C-x C-i to a key @ 2010-08-12 23:13 Markus Heller 2010-08-12 23:37 ` Andreas Burtzlaff 0 siblings, 1 reply; 9+ messages in thread From: Markus Heller @ 2010-08-12 23:13 UTC (permalink / raw To: emacs-orgmode Hello all, I'd like to bind `C-u C-c C-x C-i' to the <f10> key in emacs 23. I guess the line in my .emacs has to look like (global-set-key (kbd "<f10>") 'org-XXX-XXX) but what exactly would org-XXX-XXX be? I apologize if this is a question with an obvious answer ... Thanks and Cheers Markus ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Bind C-u C-c C-x C-i to a key 2010-08-12 23:13 Bind C-u C-c C-x C-i to a key Markus Heller @ 2010-08-12 23:37 ` Andreas Burtzlaff 2010-08-13 3:12 ` [OT] Passing universal argument to a function (was: Bind C-u C-c C-x C-i to a key) Memnon Anon 2010-08-13 7:09 ` Re: Bind C-u C-c C-x C-i to a key Bastien 0 siblings, 2 replies; 9+ messages in thread From: Andreas Burtzlaff @ 2010-08-12 23:37 UTC (permalink / raw To: Markus Heller; +Cc: emacs-orgmode Markus Heller <hellerm2@gmail.com> writes: > Hello all, > > I'd like to bind `C-u C-c C-x C-i' to the <f10> key in emacs 23. > > I guess the line in my .emacs has to look like > > (global-set-key (kbd "<f10>") 'org-XXX-XXX) > > but what exactly would org-XXX-XXX be? > > I apologize if this is a question with an obvious answer ... The C-u says that the function that is bound to the rest of the key combination is called with the first argument being `t'. To get information about the function bound to a key combination use: C-h k and then press the key combination (without the C-u prefix). In this case it is org-clock-in. This should bind org-clock-in with argument `t' to F12: (defun ab-org-clock-in-select () (interactive) (org-clock-in t)) (global-set-key (kbd "<f12>") 'ab-org-clock-in-select) Maybe there's a more elegant way I don't know about.. HTH Andreas > Thanks and Cheers > Markus > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 9+ messages in thread
* [OT] Passing universal argument to a function (was: Bind C-u C-c C-x C-i to a key) 2010-08-12 23:37 ` Andreas Burtzlaff @ 2010-08-13 3:12 ` Memnon Anon 2010-08-13 16:49 ` Markus Heller 2010-08-14 23:41 ` Docstrings: Use of `C-u' (was: [OT] Passing universal argument to a function) Memnon Anon 2010-08-13 7:09 ` Re: Bind C-u C-c C-x C-i to a key Bastien 1 sibling, 2 replies; 9+ messages in thread From: Memnon Anon @ 2010-08-13 3:12 UTC (permalink / raw To: Andreas Burtzlaff; +Cc: Markus Heller, emacs-orgmode Andreas Burtzlaff <andy13@gmx.net> writes: > The C-u says that the function that is bound to the rest of the key > combination is called with the first argument being `t'. > > To get information about the function bound to a key combination use: > C-h k > and then press the key combination (without the C-u prefix). > In this case it is org-clock-in. > > This should bind org-clock-in with argument `t' to F12: > > (defun ab-org-clock-in-select () > (interactive) > (org-clock-in t)) > > (global-set-key (kbd "<f12>") 'ab-org-clock-in-select) Mhhh, this does not work for me. ,----[ (info "(eintr)Note for Novices") ] | In addition to typing a lone keychord, you can prefix what you type | with `C-u', which is called the `universal argument'. The `C-u' | keychord passes an argument to the subsequent command. [...] | (If you do not specify a number, Emacs either passes the number 4 to | the command or otherwise runs the command differently than it would | otherwise.) `---- So, afaics C-u = Value of 4. Some googling seems to suggest that an argument of '(4) works, and it does for me: --8<---------------cut here---------------start------------->8--- (defun ab-org-clock-in-select () (interactive) (org-clock-in '(4))) --8<---------------cut here---------------end--------------->8--- or even shorter with a lambda --8<---------------cut here---------------start------------->8--- (global-set-key (kbd "C-c C-g") (lambda () (interactive) (org-clock-in '(4)))) --8<---------------cut here---------------end--------------->8--- works here! However, this faq [ (info "(efaq)Replying to the sender of a message") ] seems to suggest that your version is the way to go. ... I am confused. However, this is org OT, so I'll finish my musings here :) Go with whatever works for you. Memnon ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [OT] Passing universal argument to a function (was: Bind C-u C-c C-x C-i to a key) 2010-08-13 3:12 ` [OT] Passing universal argument to a function (was: Bind C-u C-c C-x C-i to a key) Memnon Anon @ 2010-08-13 16:49 ` Markus Heller 2010-08-14 23:41 ` Docstrings: Use of `C-u' (was: [OT] Passing universal argument to a function) Memnon Anon 1 sibling, 0 replies; 9+ messages in thread From: Markus Heller @ 2010-08-13 16:49 UTC (permalink / raw To: emacs-orgmode Memnon Anon <gegendosenfleisch@googlemail.com> writes: > Andreas Burtzlaff <andy13@gmx.net> writes: > >> The C-u says that the function that is bound to the rest of the key >> combination is called with the first argument being `t'. >> >> To get information about the function bound to a key combination use: >> C-h k >> and then press the key combination (without the C-u prefix). >> In this case it is org-clock-in. >> >> This should bind org-clock-in with argument `t' to F12: >> >> (defun ab-org-clock-in-select () >> (interactive) >> (org-clock-in t)) >> >> (global-set-key (kbd "<f12>") 'ab-org-clock-in-select) > > Mhhh, this does not work for me. > > ,----[ (info "(eintr)Note for Novices") ] > | In addition to typing a lone keychord, you can prefix what you type > | with `C-u', which is called the `universal argument'. The `C-u' > | keychord passes an argument to the subsequent command. [...] > | (If you do not specify a number, Emacs either passes the number 4 to > | the command or otherwise runs the command differently than it would > | otherwise.) > `---- > > So, afaics C-u = Value of 4. > > Some googling seems to suggest that an argument of '(4) works, > and it does for me: > > (defun ab-org-clock-in-select () > (interactive) > (org-clock-in '(4))) > > or even shorter with a lambda > > (global-set-key (kbd "C-c C-g") (lambda () (interactive) (org-clock-in '(4)))) > > works here! Works here too! Thanks a lot! > However, this faq [ (info "(efaq)Replying to the sender of a message") ] > seems to suggest that your version is the way to go. I'm not quite sure I understand this ... But again, thanks anyway! Markus > ... > > I am confused. > > However, this is org OT, so I'll finish my musings here :) > Go with whatever works for you. > > Memnon > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 9+ messages in thread
* Docstrings: Use of `C-u' (was: [OT] Passing universal argument to a function) 2010-08-13 3:12 ` [OT] Passing universal argument to a function (was: Bind C-u C-c C-x C-i to a key) Memnon Anon 2010-08-13 16:49 ` Markus Heller @ 2010-08-14 23:41 ` Memnon Anon 2010-08-16 18:54 ` Docstrings: Use of `C-u' Bastien 2010-08-16 19:01 ` Bastien 1 sibling, 2 replies; 9+ messages in thread From: Memnon Anon @ 2010-08-14 23:41 UTC (permalink / raw To: Memnon Anon; +Cc: Markus Heller, emacs-orgmode Memnon Anon <gegendosenfleisch@googlemail.com> writes: > I am confused. [I prepared a long mail, but I deleted it all. I will try to keep it short] If one wants to bind a key to `C-u C-c C-x C-i', the easiest way is to have a look at the docstring and try to figure out, how to call the function in a lambda, i.e. an unnamed function, bound to the preferred key. Right? This person usually has a look at the docstring and tries to figure out how the argument is interpreted by the function: Sure, it is *most of the times* used as an interactive funtion, but binding a key (i.e. a common task) to a function called with `C-u' via a lambda (= a non interactive call) seems to be probable action. Right? So, in orgmode, I see 'some' functions - usually called interactively - which provide a docstring like this: ,----[ org-clock.el ] | (defun org-clock-in (&optional select start-time) | "Start the clock on the current item. | If necessary, clock-out of the currently active clock. | With a prefix argument SELECT (\\[universal-argument]), offer a list of \ | recently clocked tasks to | clock into. When SELECT is \\[universal-argument] \\[universal-argument], \ | clock into the current task and mark | is as the default task, a special task that will always be offered in | the clocking selection, associated with the letter `d'." `---- which say: use universal argument. But this seems - all by itself without looking at how the argument is used in the function - uncomplete for a user who wants to call the function non-interactively. I found only one other example so far, which is different: ,----[ org-agenda.el ] | (defun org-agenda-set-restriction-lock (&optional type) | "Set restriction lock for agenda, to current subtree or file. | Restriction will be the file if TYPE is `file', or if type is the * universal prefix '(4), or if the cursor is before the first headline | in the file. Otherwise, restriction will be to the current subtree." `---- Adding that the prefix argument will be interpretated as a *list of one* integer like this -> '(4) seems great. This clarifies that the test against the prefix argument is something like "(when (equal arg '(4))" without looking at the code of the function itself. Does this make any sense? Would adding the `'(4)' part to other docstrings be welcome? ========= Info Another point I am confused about: ,----[ (info "(org)Agenda commands") ] | Remote editing | .............. | | `0-9' | Digit argument. `---- Okay, a number - as a Prefix, right? - gives a Digit argument. But what does this really do? For some commands, it works as a repeater: `5 n' in an agenda buffer moves down 5 lines. (This is not mentioned in the manual. Should it be?) But what does the Digit argument do for e.g. org-agenda-clock-out? ,----[ org-agenda.el ] | (defun org-agenda-clock-out (&optional arg) | "Stop the currently running clock." | (interactive "P") | (unless (marker-buffer org-clock-marker) | (error "No running clock")) | (let ((marker (make-marker)) newhead) | (org-with-remote-undo (marker-buffer org-clock-marker) | (with-current-buffer (marker-buffer org-clock-marker) | (save-excursion | (save-restriction | (widen) | (goto-char org-clock-marker) | (org-back-to-heading t) | (move-marker marker (point)) | (org-clock-out) | (setq newhead (org-get-heading)))))) | (org-agenda-change-all-lines newhead marker) | (move-marker marker nil))) `---- It takes an (optional) arg, but is it used anywhere?! If there is no arg interpreted anywhere, why is it there? I am *really* sorry if I waste your time on this, because it is clear to you and should be to anyone else; but I don't get. And orgmode brought me into this stuff, so where else should I ask? ;) Memnon "I should stick to latin!" Anon ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Docstrings: Use of `C-u' 2010-08-14 23:41 ` Docstrings: Use of `C-u' (was: [OT] Passing universal argument to a function) Memnon Anon @ 2010-08-16 18:54 ` Bastien 2010-08-16 19:01 ` Bastien 1 sibling, 0 replies; 9+ messages in thread From: Bastien @ 2010-08-16 18:54 UTC (permalink / raw To: Memnon Anon; +Cc: Markus Heller, emacs-orgmode Memnon Anon <gegendosenfleisch@googlemail.com> writes: > ,----[ org-agenda.el ] > | (defun org-agenda-clock-out (&optional arg) > | "Stop the currently running clock." > | (interactive "P") > | (unless (marker-buffer org-clock-marker) > | (error "No running clock")) > | (let ((marker (make-marker)) newhead) > | (org-with-remote-undo (marker-buffer org-clock-marker) > | (with-current-buffer (marker-buffer org-clock-marker) > | (save-excursion > | (save-restriction > | (widen) > | (goto-char org-clock-marker) > | (org-back-to-heading t) > | (move-marker marker (point)) > | (org-clock-out) > | (setq newhead (org-get-heading)))))) > | (org-agenda-change-all-lines newhead marker) > | (move-marker marker nil))) > `---- > > It takes an (optional) arg, but is it used anywhere?! Nope... > If there is no arg interpreted anywhere, why is it there? Looks like a mistake - I committed a fix to remove this arg. -- Bastien ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Docstrings: Use of `C-u' 2010-08-14 23:41 ` Docstrings: Use of `C-u' (was: [OT] Passing universal argument to a function) Memnon Anon 2010-08-16 18:54 ` Docstrings: Use of `C-u' Bastien @ 2010-08-16 19:01 ` Bastien 1 sibling, 0 replies; 9+ messages in thread From: Bastien @ 2010-08-16 19:01 UTC (permalink / raw To: Memnon Anon; +Cc: Markus Heller, emacs-orgmode Hi Memnon, Memnon Anon <gegendosenfleisch@googlemail.com> writes: > I found only one other example so far, which is different: > ,----[ org-agenda.el ] > | (defun org-agenda-set-restriction-lock (&optional type) > | "Set restriction lock for agenda, to current subtree or file. > | Restriction will be the file if TYPE is `file', or if type is the > * universal prefix '(4), or if the cursor is before the first headline > | in the file. Otherwise, restriction will be to the current subtree." > `---- > > Adding that the prefix argument will be interpretated as a *list of one* > integer like this -> '(4) seems great. This clarifies that the test > against the prefix argument is something like "(when (equal arg '(4))" > without looking at the code of the function itself. I agree beginners won't easily guess the prefix argument is of the form '(4). But as a beginner, I'd look for "prefix argument" in the Emacs manual and find this: http://www.gnu.org/s/emacs/manual/html_node/elisp/Prefix-Command-Arguments.html Or I'll ask this list :) In any case, I'm not sure clarification about this belongs to Org's code. Maybe we can just add a footnote in the Org's manual referring to the Emacs manual for the first important occurrence of "prefix argument" (one regarding a function that is very likely to be used in another function, or called in a lambda expression). Any suggestion? -- Bastien ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: Bind C-u C-c C-x C-i to a key 2010-08-12 23:37 ` Andreas Burtzlaff 2010-08-13 3:12 ` [OT] Passing universal argument to a function (was: Bind C-u C-c C-x C-i to a key) Memnon Anon @ 2010-08-13 7:09 ` Bastien 2010-08-13 7:12 ` Bastien 1 sibling, 1 reply; 9+ messages in thread From: Bastien @ 2010-08-13 7:09 UTC (permalink / raw To: Andreas Burtzlaff; +Cc: Markus Heller, emacs-orgmode Andreas Burtzlaff <andy13@gmx.net> writes: > (defun ab-org-clock-in-select () > (interactive) > (org-clock-in t)) > > (global-set-key (kbd "<f12>") 'ab-org-clock-in-select) > > Maybe there's a more elegant way I don't know about.. Maybe this one: (global-set-key (kbd "<f12>") (lambda() (interactive) (org-clock-in t))) -- Bastien ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: Bind C-u C-c C-x C-i to a key 2010-08-13 7:09 ` Re: Bind C-u C-c C-x C-i to a key Bastien @ 2010-08-13 7:12 ` Bastien 0 siblings, 0 replies; 9+ messages in thread From: Bastien @ 2010-08-13 7:12 UTC (permalink / raw To: Andreas Burtzlaff; +Cc: Markus Heller, emacs-orgmode Bastien <bastien.guerry@wikimedia.fr> writes: > (global-set-key (kbd "<f12>") (lambda() (interactive) (org-clock-in t))) Forget this one -- Memnon Anon's solution is right. Sorry for the noise... -- Bastien ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-08-16 19:01 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-08-12 23:13 Bind C-u C-c C-x C-i to a key Markus Heller 2010-08-12 23:37 ` Andreas Burtzlaff 2010-08-13 3:12 ` [OT] Passing universal argument to a function (was: Bind C-u C-c C-x C-i to a key) Memnon Anon 2010-08-13 16:49 ` Markus Heller 2010-08-14 23:41 ` Docstrings: Use of `C-u' (was: [OT] Passing universal argument to a function) Memnon Anon 2010-08-16 18:54 ` Docstrings: Use of `C-u' Bastien 2010-08-16 19:01 ` Bastien 2010-08-13 7:09 ` Re: Bind C-u C-c C-x C-i to a key Bastien 2010-08-13 7:12 ` Bastien
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.