all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Manuel Hermenegildo <manuel.hermenegildo@imdea.org>
To: Eric S Fraga <esflists@gmail.com>
Cc: Neil Jerram <neil@ossau.homelinux.net>, emacs-orgmode@gnu.org
Subject: Re: Adding an item to the agenda from the agenda view
Date: Mon, 5 Mar 2018 18:50:09 +0100	[thread overview]
Message-ID: <23197.33617.800219.299933@gazelle.local> (raw)
In-Reply-To: <87a7vmke4f.fsf@gmail.com>


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
;; 
;; 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 
 'org-mode-hook
 (lambda ()
   (define-key org-agenda-keymap   "+" 'my-org-agenda-capture-in-date-at-point)
   (define-key org-agenda-mode-map "+" 'my-org-agenda-capture-in-date-at-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 available)."
  (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-overriding-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. 
;; 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 
'(("+" "Special template used by + keybinding" entry 
   (file+headline "" "Auto-inserted tasks")
   "** TODO %? %(if (string= (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.
 > 
 > Hi Neil,
 > 
 > 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.
 > 
 > > I thought perhaps that Shérab meant something different, namely to
 > > capture a new TODO item that was scheduled for that date.
 > 
 > Maybe.  The post was vague.  I read it the other way.  Shérab?
 > 
 > For TODO, org-agenda-capture (bound to "k" I believe?) already does what
 > you think Shérab wanted, I would have thought?  What is missing?
 > 
 > For me, looking at dates in the agenda is about checking availability
 > and this usually means I am looking at creating a new appointment.  "i
 > d" is perfect for this.
 > 
 > 
 > -- 
 > Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-191-g90607d
 > x[DELETED ATTACHMENT signature.asc, application/pgp-signature]

-- 
-------------------------------------------------------------------------
 Manuel Hermenegildo                       manuel.hermenegildo@imdea.org
-------------------------------------------------------------------------

  reply	other threads:[~2018-03-05 17:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-04 22:22 Adding an item to the agenda from the agenda view Shérab
2018-03-05  6:52 ` Eric S Fraga
2018-03-05  9:05   ` Neil Jerram
2018-03-05 10:31     ` Eric S Fraga
2018-03-05 17:50       ` Manuel Hermenegildo [this message]
2018-03-05 19:20       ` Eduardo Mercovich
2018-03-06 21:15         ` Shérab
2018-03-06 23:06           ` Eric Abrahamsen
2018-03-07  7:13           ` Eric S Fraga
2018-03-09 19:23             ` Shérab
2018-03-09 21:27               ` Nick Dokos
2018-03-09 21:45                 ` Shérab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23197.33617.800219.299933@gazelle.local \
    --to=manuel.hermenegildo@imdea.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=esflists@gmail.com \
    --cc=neil@ossau.homelinux.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.