emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Allow user to limit amount of context stored in file link search strings
@ 2010-12-05 18:24 Matt Lundin
  2010-12-06  9:06 ` [Accepted] " Carsten Dominik
  2010-12-06  9:20 ` Shared subtrees? Samium Gromoff
  0 siblings, 2 replies; 7+ messages in thread
From: Matt Lundin @ 2010-12-05 18:24 UTC (permalink / raw)
  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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Accepted] Allow user to limit amount of context stored in file link search strings
  2010-12-05 18:24 [PATCH] Allow user to limit amount of context stored in file link search strings Matt Lundin
@ 2010-12-06  9:06 ` Carsten Dominik
  2010-12-06  9:20 ` Shared subtrees? Samium Gromoff
  1 sibling, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2010-12-06  9:06 UTC (permalink / raw)
  To: emacs-orgmode

Patch 440 (http://patchwork.newartisans.com/patch/440/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C87y6843wiu.fsf%40fastmail.fm%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [Orgmode] Allow user to limit amount of context stored in file link
> 	search strings
> Date: Sun, 05 Dec 2010 23:24:13 -0000
> From: Matt Lundin <mdl@imapmail.org>
> X-Patchwork-Id: 440
> Message-Id: <87y6843wiu.fsf@fastmail.fm>
> To: Org Mode <emacs-orgmode@gnu.org>
> 
> * 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)
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Shared subtrees?
  2010-12-05 18:24 [PATCH] Allow user to limit amount of context stored in file link search strings Matt Lundin
  2010-12-06  9:06 ` [Accepted] " Carsten Dominik
@ 2010-12-06  9:20 ` Samium Gromoff
  2010-12-06 17:43   ` Samuel Wales
  1 sibling, 1 reply; 7+ messages in thread
From: Samium Gromoff @ 2010-12-06  9:20 UTC (permalink / raw)
  To: Org Mode

Good day folks,

Did anybody ever have a desire to have Org operate not just on a tree,
but on a partial order, effectively allowing shared subtrees?

Since we cannot use plain text to directly represent partial orders in
general, we would have to store each shared subnode multiple times,
in each place it is referenced, and to maintain the equivalence
across the set of these "treeification points" of the partial order.

-- 
regards,
  Samium Gromoff
--
"Actually I made up the term 'object-oriented', and I can tell you I
did not have C++ in mind." - Alan Kay (OOPSLA 1997 Keynote)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Shared subtrees?
  2010-12-06  9:20 ` Shared subtrees? Samium Gromoff
@ 2010-12-06 17:43   ` Samuel Wales
  2010-12-06 21:17     ` Samium Gromoff
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Wales @ 2010-12-06 17:43 UTC (permalink / raw)
  To: Samium Gromoff; +Cc: Org Mode

Perhaps you can provide examples?  I am not sure if you are referring
to virtual nodes (virtual regions do not exist in current Emacs,
although it would be good; kludges might be possible with e.g.
overlays but are not ideal), graph theoretic structures (ID markers
implement this in a general way), including text in export (we've
discussed it but not come up with a general solution yet), or
something else.

Org has a philosophy of not duplicating ever.

I have unpublished notes on some of these topics.


Samuel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Shared subtrees?
  2010-12-06 17:43   ` Samuel Wales
@ 2010-12-06 21:17     ` Samium Gromoff
  2010-12-06 21:43       ` Samuel Wales
  0 siblings, 1 reply; 7+ messages in thread
From: Samium Gromoff @ 2010-12-06 21:17 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Org Mode

On Mon, 6 Dec 2010 10:43:17 -0700, Samuel Wales <samologist@gmail.com> wrote:
> Perhaps you can provide examples?  I am not sure if you are referring
> to virtual nodes (virtual regions do not exist in current Emacs,
> although it would be good; kludges might be possible with e.g.
> overlays but are not ideal), graph theoretic structures (ID markers
> implement this in a general way), including text in export (we've
> discussed it but not come up with a general solution yet), or
> something else.

With ten minutes of googling I couldn't figure out what virtual nodes
correspond to, in the context of Emacs (modulo the somewhat irrelevant
Info's virtual-nodes), besides them sounding like something vaguely useful
in implementing the feature I had in mind.

Virtual regions (a presentation of something of synthetic nature, which
is not directly backed by a buffer's region) sound exactly like the best
building block I'd imagine for the implementation of the said feature.

I did refer to the concept of 'partial order', a graph-theoretic
structure indeed.  I did so to illustrate the difference with the usual
tree, where no branches ever join, so none of them ever share identical
children.

I did not refer to including text in export, I'm more interested in the
editing of the partial order.

-- 
regards,
  Samium Gromoff
--
"Actually I made up the term 'object-oriented', and I can tell you I
did not have C++ in mind." - Alan Kay (OOPSLA 1997 Keynote)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Shared subtrees?
  2010-12-06 21:17     ` Samium Gromoff
@ 2010-12-06 21:43       ` Samuel Wales
  2010-12-06 21:44         ` Samuel Wales
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Wales @ 2010-12-06 21:43 UTC (permalink / raw)
  To: Samium Gromoff; +Cc: Org Mode

Partial order can refer to more than one concept in org.

You could bring the underlying Emacs technology you seek up on
emacs-devel and see what people say.

What I seek is more akin to an indirect buffer.  What you seek might not be.

Hope it helps.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Shared subtrees?
  2010-12-06 21:43       ` Samuel Wales
@ 2010-12-06 21:44         ` Samuel Wales
  0 siblings, 0 replies; 7+ messages in thread
From: Samuel Wales @ 2010-12-06 21:44 UTC (permalink / raw)
  To: Samium Gromoff; +Cc: Org Mode

On 2010-12-06, Samuel Wales <samologist@gmail.com> wrote:
> What I seek is more akin to an indirect buffer.  What you seek might not

I take something "synthetic" to not be like an indirect buffer.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-12-06 21:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-05 18:24 [PATCH] Allow user to limit amount of context stored in file link search strings Matt Lundin
2010-12-06  9:06 ` [Accepted] " Carsten Dominik
2010-12-06  9:20 ` Shared subtrees? Samium Gromoff
2010-12-06 17:43   ` Samuel Wales
2010-12-06 21:17     ` Samium Gromoff
2010-12-06 21:43       ` Samuel Wales
2010-12-06 21:44         ` Samuel Wales

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).