From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: [PATCH] Allow user to limit amount of context stored in file link search strings Date: Sun, 5 Dec 2010 13:24:13 -0500 Message-ID: <87y6843wiu.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=39010 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPJJE-0003v7-QR for emacs-orgmode@gnu.org; Sun, 05 Dec 2010 13:27:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPJJD-0004iN-K0 for emacs-orgmode@gnu.org; Sun, 05 Dec 2010 13:27:40 -0500 Received: from out1.smtp.messagingengine.com ([66.111.4.25]:53618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPJJD-0004iA-Dg for emacs-orgmode@gnu.org; Sun, 05 Dec 2010 13:27:39 -0500 Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.messagingengine.com (Postfix) with ESMTP id 06E4A4DF for ; Sun, 5 Dec 2010 13:27:39 -0500 (EST) Received: from archdesk (67-197-63-212.rh2.dyn.cm.comporium.net [67.197.63.212]) by mail.messagingengine.com (Postfix) with ESMTPSA id 99FA05E31F6 for ; Sun, 5 Dec 2010 13:27:38 -0500 (EST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode * lisp/org.el: (org-make-heading-search-string) Optionally limit number of lines stored in file link search strings. (org-context-in-file-links) Add option to set to integer specifying number of lines. --- lisp/org.el | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 66514a2..2d769be 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -1385,12 +1385,15 @@ nil Never use an ID to make a link, instead link using a text search for (defcustom org-context-in-file-links t "Non-nil means file links from `org-store-link' contain context. A search string will be added to the file name with :: as separator and -used to find the context when the link is activated by the command -`org-open-at-point'. +used to find the context when the link is activated by the command +`org-open-at-point'. When this option is t, the entire active region +will be placed in the search string of the file link. If set to a +positive integer, only the first n lines of context will be stored. + Using a prefix arg to the command \\[org-store-link] (`org-store-link') negates this setting for the duration of the command." :group 'org-link-store - :type 'boolean) + :type '(choice boolean integer)) (defcustom org-keep-stored-link-after-insertion nil "Non-nil means keep link in list for entire session. @@ -8501,7 +8504,8 @@ according to FMT (default from `org-email-link-description-format')." (defun org-make-org-heading-search-string (&optional string heading) "Make search string for STRING or current headline." (interactive) - (let ((s (or string (org-get-heading)))) + (let ((s (or string (org-get-heading))) + (lines org-context-in-file-links)) (unless (and string (not heading)) ;; We are using a headline, clean up garbage in there. (if (string-match org-todo-regexp s) @@ -8515,6 +8519,13 @@ according to FMT (default from `org-email-link-description-format')." (while (string-match org-ts-regexp s) (setq s (replace-match "" t t s)))) (or string (setq s (concat "*" s))) ; Add * for headlines + (when (and string (integerp lines) (> lines 0)) + (let ((slines (org-split-string s "\n"))) + (when (< lines (length slines)) + (setq s (mapconcat + 'identity + (reverse (nthcdr (- (length slines) lines) + (reverse slines))) "\n"))))) (mapconcat 'identity (org-split-string s "[ \t]+") " "))) (defun org-make-link (&rest strings) -- 1.7.3.2