From mboxrd@z Thu Jan 1 00:00:00 1970 From: Manuel Hermenegildo Subject: Re: Adding an item to the agenda from the agenda view Date: Mon, 5 Mar 2018 18:50:09 +0100 Message-ID: <23197.33617.800219.299933@gazelle.local> References: <20180304222205.GA32697@pema> <87fu5fko93.fsf@gmail.com> <87a7vmke4f.fsf@gmail.com> Reply-To: Manuel Hermenegildo Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esuFj-0001NQ-2w for emacs-orgmode@gnu.org; Mon, 05 Mar 2018 12:50:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1esuFd-0006Sa-Vv for emacs-orgmode@gnu.org; Mon, 05 Mar 2018 12:50:23 -0500 Received: from cliplab.org ([193.147.107.22]:32891) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1esuFd-0006Nl-OO for emacs-orgmode@gnu.org; Mon, 05 Mar 2018 12:50:17 -0500 In-Reply-To: <87a7vmke4f.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Eric S Fraga Cc: Neil Jerram , emacs-orgmode@gnu.org I enclose some code that I find quite useful for this purpose (i.e., to get a similar "feel" to inserting tasks in a traditional agenda). It basically uses capture but speeds things up a bit and allows taking times from an agenda time grid. Cheers, --Manuel ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; A handy shortcut to use capture in today in agenda ;;=20 ;; The idea is that you type "+" while at an agenda day, fill in the ;; TODO that pops up, and type "C-CC-c": the TODO gets added to the ;; first file in your org-agenda-files, after an "* Auto-inserted ;; tasks" entry. It also tries to capture the time if you are on an ;; agenda schedule. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Use the current date when possible (setq org-capture-use-agenda-date t) ;; Recalculate agenda after captures (add-hook 'org-capture-after-finalize-hook 'org-agenda-redo) ;; Key binding (+) (add-hook=20 'org-mode-hook (lambda () (define-key org-agenda-keymap "+" 'my-org-agenda-capture-in-date-a= t-point) (define-key org-agenda-mode-map "+" 'my-org-agenda-capture-in-date-a= t-point) )) ;; Quick interface to capture (defun my-org-agenda-capture-in-date-at-point () "Call parts of `org-capture' with the date at point (and time if avai= lable)." (interactive) (if (not (eq major-mode 'org-agenda-mode)) (user-error "You cannot do this outside of agenda buffers") (let ((org-overriding-default-time (org-get-cursor-date t))) ; (print (concat "*** " (format-time-string "%F %T" org-overridin= g-default-time))) (org-capture 1 "+") ))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;; ;; Connection w/org-capture ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;; ;; The org file in which tasks are inserted. An entry: ;; "* Auto-inserted tasks" ;; should exist in that file.=20 ;; In this case we take the first org file in org-agenda-files: (setq org-default-notes-file (car org-agenda-files)) ;; The capture template (You may have other org-capture-templates -- ;; in that case simply add this one to the list) (setq org-capture-templates=20 '(("+" "Special template used by + keybinding" entry=20 (file+headline "" "Auto-inserted tasks") "** TODO %=3F %(if (string=3D (substring \"%T\" 16 21) \"00:00\") \"= %t\" \"%T\")" :prepend t :empty-lines-after 1) )) On Monday, March 5, 2018 at 10:31:28 (+0000), Eric S Fraga wrote: > On Monday, 5 Mar 2018 at 09:05, Neil Jerram wrote: > > Eric, > > > > IIUC, that would add an entry to the 'diary' file. >=20 > Hi Neil, >=20 > You are correct. However, if you have defined org-agenda-diary-file= , an > org entry is added via org-agenda-diary-entry-in-org-file. >=20 > > I thought perhaps that Sh=E9rab meant something different, namely = to > > capture a new TODO item that was scheduled for that date. >=20 > Maybe. The post was vague. I read it the other way. Sh=E9rab=3F >=20 > For TODO, org-agenda-capture (bound to "k" I believe=3F) already doe= s what > you think Sh=E9rab wanted, I would have thought=3F What is missing=3F= >=20 > For me, looking at dates in the agenda is about checking availabilit= y > and this usually means I am looking at creating a new appointment. = "i > d" is perfect for this. >=20 >=20 > --=20 > Eric S Fraga via Emacs 27.0.50, Org release=5F9.1.6-191-g90607d > x[DELETED ATTACHMENT signature.asc, application/pgp-signature] --=20 -----------------------------------------------------------------------= -- Manuel Hermenegildo manuel.hermenegildo@imdea.or= g -----------------------------------------------------------------------= --