From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Bulk cut in agenda view Date: Mon, 11 Jul 2011 21:50:21 +0200 Message-ID: <87sjqcbnr6.fsf@gnu.org> References: <87box2fb3i.fsf@free.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:50790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QgMUb-0002Rd-KR for emacs-orgmode@gnu.org; Mon, 11 Jul 2011 15:50:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QgMUV-0006HQ-Ny for emacs-orgmode@gnu.org; Mon, 11 Jul 2011 15:50:08 -0400 Received: from mail-fx0-f52.google.com ([209.85.161.52]:37727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QgMUU-0006G0-Oc for emacs-orgmode@gnu.org; Mon, 11 Jul 2011 15:50:03 -0400 Received: by fxd18 with SMTP id 18so621656fxd.39 for ; Mon, 11 Jul 2011 12:49:58 -0700 (PDT) In-Reply-To: <87box2fb3i.fsf@free.fr> (Julien Cubizolles's message of "Sun, 10 Jul 2011 16:45:37 +0200") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Julien Cubizolles Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi Julien, Julien Cubizolles writes: > I often need to purge DONE items from my org files. I have set up a > special agenda view for checking those items and cutting some subtrees > from it using bulk commands. I'm using a function adapted from the > example in the manual (I've no idea if it's the best way to do it > however) : > > ,---- > | (defun bulk-cut () > | (interactive "P") > | (let* ((marker (or (org-get-at-bol 'org-hd-marker) > | (org-agenda-error))) > | (buffer (marker-buffer marker))) > | (with-current-buffer buffer > | (save-excursion > | (save-restriction > | (widen) > | (goto-char marker) > | (org-back-to-heading t) > | (org-cut-subtree)))))) > `---- > > Typing B f bulk-cut RET removes the selected items but it's a lot of > typing for a very useful action in my opinion. > > Could it be added to the list of default bulk actions, with a "X" key > for example ? Please test this patch and try to set `org-agenda-bulk-custom-functions' (see the docstring). Thanks for bringing this up! --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-agenda.el-New-variable-for-custom-bulk-action-fu.patch >From 0c90c476015f4b9e20199df30652bb341fd0d811 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 11 Jul 2011 21:48:44 +0200 Subject: [PATCH] org-agenda.el: New variable for custom bulk action functions. * org-agenda.el (org-agenda-bulk-custom-functions): New variable for custom bulk action functions. (org-agenda-bulk-action): Use it. Thanks to Julien Cubizolles for triggering this idea. --- lisp/org-agenda.el | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 37f8e84..4209b45 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1695,6 +1695,19 @@ the lower-case version of all tags." :group 'org-agenda :type 'function) +(defcustom org-agenda-bulk-custom-functions nil + "Alist of characters and custom functions for bulk action. +For example, this value makes those two functions available: + + '((?R set-category) + (?C bulk-cut)) + +With selected entries in an agenda buffer, `B R' will execute +set-category on the selected entries. Note that functions in +this alist don't need to be quoted." + :type 'alist + :group 'org-agenda) + (eval-when-compile (require 'cl)) (require 'org) @@ -8149,7 +8162,13 @@ The prefix arg is passed through to the command if possible." org-agenda-bulk-marked-entries) ;; Prompt for the bulk command - (message "Bulk: [r]efile [$]arch [A]rch->sib [t]odo [+/-]tag [s]chd [S]catter [d]eadline [f]unction") + (message (concat "Bulk: [r]efile [$]arch [A]rch->sib [t]odo" + " [+/-]tag [s]chd [S]catter [d]eadline [f]unction" + (when org-agenda-bulk-custom-functions + (concat " Custom: [" + (mapconcat (lambda(f) (char-to-string (car f))) + org-agenda-bulk-custom-functions "") + "]")))) (let* ((action (read-char-exclusive)) (org-log-refile (if org-log-refile 'time nil)) (entries (reverse org-agenda-bulk-marked-entries)) @@ -8243,6 +8262,10 @@ The prefix arg is passed through to the command if possible." (org-agenda-schedule nil time)) (error nil))))))) + ((assoc action org-agenda-bulk-custom-functions) + (setq cmd (list (cadr (assoc action org-agenda-bulk-custom-functions))) + redo-at-end t)) + ((equal action ?f) (setq cmd (list (intern (org-icompleting-read "Function: " -- 1.7.5.2 --=-=-= Content-Type: text/plain -- Bastien --=-=-=--