From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH 2/5] Immediately return if scope is region but no region is active Date: Thu, 25 Aug 2011 07:43:48 +0200 Message-ID: References: <87obzpl3ec.fsf@gnu.org> <1314246334-5053-3-git-send-email-dmaus@ictsoc.de> Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:37344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTtG-0006eP-EW for emacs-orgmode@gnu.org; Thu, 25 Aug 2011 02:58:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QwTtF-0006Eh-5n for emacs-orgmode@gnu.org; Thu, 25 Aug 2011 02:58:14 -0400 Received: from mail-ey0-f171.google.com ([209.85.215.171]:57558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTtE-0006EK-U0 for emacs-orgmode@gnu.org; Thu, 25 Aug 2011 02:58:13 -0400 Received: by mail-ey0-f171.google.com with SMTP id 24so1871127eyg.30 for ; Wed, 24 Aug 2011 23:58:12 -0700 (PDT) In-Reply-To: <1314246334-5053-3-git-send-email-dmaus@ictsoc.de> 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: David Maus Cc: emacs-orgmode@gnu.org On 25.8.2011, at 06:25, David Maus wrote: > * org.el (org-map-entries): Immediately return if scope is region but > no region is active. > --- > lisp/org.el | 116 = ++++++++++++++++++++++++++++++----------------------------- > 1 files changed, 59 insertions(+), 57 deletions(-) >=20 > diff --git a/lisp/org.el b/lisp/org.el > index b69b77c..27bad52 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -13608,65 +13608,67 @@ with `org-get-tags-at'. If your function = gets properties with > to t around the call to `org-entry-properties' to get the same = speedup. > Note that if your function moves around to retrieve tags and = properties at > a *different* entry, you cannot use these techniques." > - (let* ((org-agenda-archives-mode nil) ; just to make sure > - (org-agenda-skip-archived-trees (memq 'archive skip)) > - (org-agenda-skip-comment-trees (memq 'comment skip)) > - (org-agenda-skip-function > - (car (org-delete-all '(comment archive) skip))) > - (org-tags-match-list-sublevels t) > - matcher file res > - org-todo-keywords-for-agenda > - org-done-keywords-for-agenda > - org-todo-keyword-alist-for-agenda > - org-drawers-for-agenda > - org-tag-alist-for-agenda) > + (unless (and (eq scope 'region) > + (not (org-region-active-p))) Would it be good to throw an error here? (if (and (eq scope 'region) (not (org-region-active-p))) (error "No active region") ... > + (let* ((org-agenda-archives-mode nil) ; just to make sure > + (org-agenda-skip-archived-trees (memq 'archive skip)) > + (org-agenda-skip-comment-trees (memq 'comment skip)) > + (org-agenda-skip-function > + (car (org-delete-all '(comment archive) skip))) > + (org-tags-match-list-sublevels t) > + matcher file res > + org-todo-keywords-for-agenda > + org-done-keywords-for-agenda > + org-todo-keyword-alist-for-agenda > + org-drawers-for-agenda > + org-tag-alist-for-agenda) >=20 > - (cond > - ((eq match t) (setq matcher t)) > - ((eq match nil) (setq matcher t)) > - (t (setq matcher (if match (cdr (org-make-tags-matcher match)) = t)))) > + (cond > + ((eq match t) (setq matcher t)) > + ((eq match nil) (setq matcher t)) > + (t (setq matcher (if match (cdr (org-make-tags-matcher match)) = t)))) >=20 > - (save-excursion > - (save-restriction > - (cond ((eq scope 'tree) > - (org-back-to-heading t) > - (org-narrow-to-subtree) > - (setq scope nil)) > - ((and (eq scope 'region) (org-region-active-p)) > - (let ((end (save-excursion > - (goto-char (region-end)) > - (outline-next-heading) > - (point)))) > - (narrow-to-region (region-beginning) end) > - (setq scope nil)))) > - > - (if (not scope) > - (progn > - (org-prepare-agenda-buffers > - (list (buffer-file-name (current-buffer)))) > - (setq res (org-scan-tags func matcher))) > - ;; Get the right scope > - (cond > - ((and scope (listp scope) (symbolp (car scope))) > - (setq scope (eval scope))) > - ((eq scope 'agenda) > - (setq scope (org-agenda-files t))) > - ((eq scope 'agenda-with-archives) > - (setq scope (org-agenda-files t)) > - (setq scope (org-add-archive-files scope))) > - ((eq scope 'file) > - (setq scope (list (buffer-file-name)))) > - ((eq scope 'file-with-archives) > - (setq scope (org-add-archive-files (list = (buffer-file-name)))))) > - (org-prepare-agenda-buffers scope) > - (while (setq file (pop scope)) > - (with-current-buffer (org-find-base-buffer-visiting file) > - (save-excursion > - (save-restriction > - (widen) > - (goto-char (point-min)) > - (setq res (append res (org-scan-tags func = matcher)))))))))) > - res)) > + (save-excursion > + (save-restriction > + (cond ((eq scope 'tree) > + (org-back-to-heading t) > + (org-narrow-to-subtree) > + (setq scope nil)) > + ((eq scope 'region) > + (let ((end (save-excursion > + (goto-char (region-end)) > + (outline-next-heading) > + (point)))) > + (narrow-to-region (region-beginning) end) > + (setq scope nil)))) > + > + (if (not scope) > + (progn > + (org-prepare-agenda-buffers > + (list (buffer-file-name (current-buffer)))) > + (setq res (org-scan-tags func matcher))) > + ;; Get the right scope > + (cond > + ((and scope (listp scope) (symbolp (car scope))) > + (setq scope (eval scope))) > + ((eq scope 'agenda) > + (setq scope (org-agenda-files t))) > + ((eq scope 'agenda-with-archives) > + (setq scope (org-agenda-files t)) > + (setq scope (org-add-archive-files scope))) > + ((eq scope 'file) > + (setq scope (list (buffer-file-name)))) > + ((eq scope 'file-with-archives) > + (setq scope (org-add-archive-files (list = (buffer-file-name)))))) > + (org-prepare-agenda-buffers scope) > + (while (setq file (pop scope)) > + (with-current-buffer (org-find-base-buffer-visiting file) > + (save-excursion > + (save-restriction > + (widen) > + (goto-char (point-min)) > + (setq res (append res (org-scan-tags func = matcher)))))))))) > + res))) >=20 > ;;;; Properties >=20 > --=20 > 1.7.2.5 >=20 >=20