From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin Drieu Subject: [PATCH] Add shortcuts to org-clock-select-task Date: Mon, 24 Jan 2011 20:03:48 +0100 Message-ID: <87hbcynmy3.fsf@home.drieu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=37741 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhRiG-0006a3-2I for emacs-orgmode@gnu.org; Mon, 24 Jan 2011 14:04:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhRho-0000Hu-Ga for emacs-orgmode@gnu.org; Mon, 24 Jan 2011 14:04:27 -0500 Received: from coloc.drieu.org ([92.243.28.86]:57884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhRho-0000Fj-04 for emacs-orgmode@gnu.org; Mon, 24 Jan 2011 14:04:00 -0500 Received: from home.drieu.org (home.drieu.org [82.225.206.200]) by coloc.drieu.org (Postfix) with ESMTPS id 200B622A58 for ; Mon, 24 Jan 2011 20:03:54 +0100 (CET) Received: from benj by home.drieu.org with local (Exim 4.72) (envelope-from ) id 1PhRhg-0004QQ-FF for emacs-orgmode@gnu.org; Mon, 24 Jan 2011 20:03:52 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi Org-moders, I am often frustrated because I clock a lot of things and some of them are repeated (i.e, coffee, read mails, etc.). So when I want to clock time I spend drinking coffee, the best I found was to search for a headline matching "Coffee". Or to tag frequent clocks and do some agenda research on this tag. Too long. :-) So here is a solution for this need : to add a shortcut property to entries I would like to "bookmark" and insert matching entries in the org-clock-select-task menu. This can be done with : * TODO Pause and drink coffee :PROPERTIES: :SHORTCUT: p :END: then C-u C-c C-x C-i p. And voil=E0, "Pause and drink coffee" is clocked= ! Here is a patch that adds a hook into org-clock-select-task and a module that adds the shortcut feature. I tried to be the least intrusive possible, if this proves to be useful, the hook trick might not be needed. Benj --=20 * Benjamin Drieu - http://www.april.org/ * Soutenez le logiciel libre, rejoignez l'April http://www.april.org/association/campagne-adhesion/ * La comptabilit=E9 personnelle libre pour tous - http://grisbi.org/ --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-shortcuts.el Content-Transfer-Encoding: quoted-printable ;;; org-shortcuts.el --- Clocking shortcuts=20=20 ;; Copyright (C) 2011 Benjamin Drieu ;; Author: Benjamin Drieu ;; Keywords:=20 ;; ;; This file is NOT part of GNU Emacs. ;; ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;; ;; ;;; Commentary: ;; This file contains the code for defining shortcuts to Org-mode ;; clocking. ;; A hook must be added to org-clock-select-task in order to insert ;; shortcuts : ;; (add-hook 'org-clock-select-task-hook 'org-clock-insert-shortcuts) ;; To enter new shortcuts, just add a SHORTCUT property to an entry: ;; ;; :PROPERTIES: ;; :SHORTCUT: x ;; :END:"))) ;; ;; After that, when `org-clock-select-task' is called, shortcuts are ;; added so that regularly clocked tasks are shown. Of course, a ;; shortcut may only be one letter long and "i" and "d" should be ;; avoided or conflicts will happen with default letters. ;;; Code: (defcustom org-clock-shortcut-property "SHORTCUT" "Name of the property that contains shortcuts." :type 'string :group 'org-clock) (defun org-clock-insert-shortcuts () "Insert shortcuts to various tasks in current buffer. Most probably will this be called from org-clock-select-task via a hook. To enter new shortcuts, just add a SHORTCUT property to an entry: :PROPERTIES: :SHORTCUT: x :END:" (let ((markers nil)) (save-excursion (save-window-excursion (mapc (lambda (b) (when (and (with-current-buffer b (org-mode-p)) (with-current-buffer b buffer-file-name)) (switch-to-buffer b) (org-scan-tags=20 '(add-to-list 'markers (set-marker (make-marker) (point))) '(org-entry-get nil org-clock-shortcut-property)))) (buffer-list)))) (if markers (progn (insert (org-add-props "Shortcuts\n" nil 'face 'bold)) (mapc (lambda (m) (when (marker-buffer m) (setq i (1+ i) s (org-clock-insert-selection-line (string-to-char (org-entry-get m "SHORTCUT")) m)) (if (fboundp 'int-to-char) (setf (car s) (int-to-char (car s)))) (push s sel-list))) markers))))) (provide 'org-shortcuts) --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=org-shortcuts.patch diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 17fccae..8f2f353 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -420,6 +420,7 @@ of a different task.") (if (fboundp 'int-to-char) (setf (car s) (int-to-char (car s)))) (push s sel-list))) org-clock-history) + (run-hooks 'org-clock-select-task-hook) (org-fit-window-to-buffer) (message (or prompt "Select task for clocking:")) (setq rpl (read-char-exclusive)) --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iD8DBQFNPc0UnDLqtZBL50ERAg26AKCR7nLubJ/gwoov3i2C3J6Y+68KhQCg1o7c wxwe8GSiEkbh0CanUUaPA6Y= =8jiD -----END PGP SIGNATURE----- --==-=-=-- --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --=-=-=--