From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Abd=C3=B3?= Roig-Maranges Subject: display outline headings up to certain level in search-view Date: Fri, 14 Dec 2012 18:46:11 +0100 Message-ID: <87mwxgplwc.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:47928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjZKz-0006yV-Du for emacs-orgmode@gnu.org; Fri, 14 Dec 2012 12:46:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjZKy-0002cH-94 for emacs-orgmode@gnu.org; Fri, 14 Dec 2012 12:46:17 -0500 Received: from mail-wi0-f173.google.com ([209.85.212.173]:35660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjZKy-0002cC-2q for emacs-orgmode@gnu.org; Fri, 14 Dec 2012 12:46:16 -0500 Received: by mail-wi0-f173.google.com with SMTP id hn17so638358wib.12 for ; Fri, 14 Dec 2012 09:46:14 -0800 (PST) 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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi, Let's say I have an org file structured like this * Project 1 ** Tasks foo ** Ideas * Project 2 ** Tasks bar When I search 'foo' I'd like the agenda search-view to display 'Project 1' instead of the closer, but less informative 'Tasks' The attached patch solves this by adding a configuration parameter that sets the maximum outline level for the headings displayed in the results of a search-view. This way, I can have a custom search on the above org file with org-agenda-search-view-max-outline-level set to 1. Abdó Roig. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=maxlevel.patch Content-Description: patch >From 830acc3fe6e7235618df080f7b6878234cb831c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abd=C3=B3=20Roig-Maranges?= Date: Wed, 12 Dec 2012 20:52:40 +0100 Subject: [PATCH] set max level to display in search-view results * lisp/org-agenda.el (org-search-view) Adds the config setting org-agenda-search-view-max-outline-level that limits the depth of items on an agenda-search-view results. When a match is found, displays the innermost outline heading containing the match such that its level does not exceed org-agenda-search-view-max-outline-level. --- lisp/org-agenda.el | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 5343887..0b85b9c 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1320,6 +1320,12 @@ When nil, they may also match part of a word." :version "24.1" :type 'boolean) +(defcustom org-agenda-search-view-max-outline-level nil + "Maximum outline level to display in search view." + :group 'org-agenda-search-view + :version "24.3" + :type 'integer) + (defgroup org-agenda-time-grid nil "Options concerning the time grid in the Org-mode Agenda." :tag "Org Agenda Time Grid" @@ -4397,10 +4403,22 @@ in `org-agenda-text-search-extra-files'." (goto-char (max (point-min) (1- (point)))) (while (re-search-forward regexp nil t) (org-back-to-heading t) + (while (and org-agenda-search-view-max-outline-level + (> (org-reduced-level (org-outline-level)) org-agenda-search-view-max-outline-level) + (forward-line -1) + (outline-back-to-heading t))) + (skip-chars-forward "* ") (setq beg (point-at-bol) beg1 (point) - end (progn (outline-next-heading) (point))) + end (progn + (outline-next-heading) + (while (and org-agenda-search-view-max-outline-level + (> (org-reduced-level (org-outline-level)) org-agenda-search-view-max-outline-level) + (forward-line 1) + (outline-next-heading))) + (point))) + (catch :skip (goto-char beg) (org-agenda-skip) -- 1.8.0.2 --=-=-=--