emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Question: org-remember and level>1 target headline
@ 2010-05-10 17:40 Martin Pohlack
  2010-05-11  9:18 ` Martin Pohlack
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Pohlack @ 2010-05-10 17:40 UTC (permalink / raw)
  To: org-mode

Hi all,

to practically prevent merge conflicts between the different machines
that I use I want to capture new items not directly under the global
"Inbox" headline, but under "Inbox/$HOSTNAME".

For example, I often capture new items on my desktop and my notebook
and later sync.  The new items will always conflict as they are placed as
last child of "Inbox".

I now switched my org-remember templates from statically specifying
"Inbox" as target headline to a helper function:

----------------------------------------------------------------------

(defun my-host-name ()
  "Returns the name of the current host minus the domain."
  (let ((hostname (downcase (system-name))))
    (save-match-data
      (substring hostname (string-match "^[^.]+" hostname) (match-end 0)))))

(defun my-org-remember-headline ()
  (concatenate 'string "Inbox/" (my-host-name)))

----------------------------------------------------------------------

The problem now is that I would like the target to be:

* Inbox
*** $HOSTNAME
***** new item

Instead, I get this:

* Inbox/$HOSTNAME
*** new items

My question now is how to specify the headline hierarchy here?

Cheers,
Martin

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

* Re: Question: org-remember and level>1 target headline
  2010-05-10 17:40 Question: org-remember and level>1 target headline Martin Pohlack
@ 2010-05-11  9:18 ` Martin Pohlack
  2010-05-13 15:48   ` Martin Pohlack
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Pohlack @ 2010-05-11  9:18 UTC (permalink / raw)
  To: org-mode

Let my rephrase the question.

How do I specify the target for a org-remember template such that new 
entries become children of "b":

* a
** b
*** new entry

If I specify "a/b", a new node named "a/b" is created

* a
** b
* a/b
** new entry

Cheers,
Martin

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

* Re: Question: org-remember and level>1 target headline
  2010-05-11  9:18 ` Martin Pohlack
@ 2010-05-13 15:48   ` Martin Pohlack
  2010-05-13 17:26     ` Eric S Fraga
  2010-05-14  3:42     ` Samuel Wales
  0 siblings, 2 replies; 12+ messages in thread
From: Martin Pohlack @ 2010-05-13 15:48 UTC (permalink / raw)
  To: org-mode

Hi,

interest in this problem was indicated to me in private mail, so let my
sum up my findings so far.

I walked through the code in org-remember.el:org-remember-handler.

There seems to be no support for path traversal for the non-interactive
case.  The first headline matching is found regardless of its depth.

I now use the following structure for my plan files:

* Inbox
*** Inbox:host1
*** Inbox:host2
*** Inbox:host3

I use these two functions for computing the current target headline:

----------------------------------------------------------------------
(defun my-host-name ()
  "Returns the name of the current host minus the domain."
  (let ((hostname (downcase (system-name))))
    (save-match-data
      (substring hostname (string-match "^[^.]+" hostname)
                          (match-end 0)))))

(defun my-org-remember-headline ()
  (concatenate 'string "Inbox:" (my-host-name)))
----------------------------------------------------------------------

In one of the interactive paths in org-remember-handler, org-refile
infrastructure is used for inquiring a target from the user.  When
refiling, "/" in headline names are replaced with "\".  Verbatim "\" in
headlines are also presented as "\".  That means that "test/test" and
"test\test" cannot be distinguished for refiling.

Is there a specification of what are valid characters in a headline?

Is there interest to define remember targets via paths or via ID?

Cheers,
Martin

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

* Re: Question: org-remember and level>1 target headline
  2010-05-13 15:48   ` Martin Pohlack
@ 2010-05-13 17:26     ` Eric S Fraga
  2010-05-14  3:42     ` Samuel Wales
  1 sibling, 0 replies; 12+ messages in thread
From: Eric S Fraga @ 2010-05-13 17:26 UTC (permalink / raw)
  To: Martin Pohlack; +Cc: org-mode

[-- Attachment #1: Type: text/plain, Size: 387 bytes --]

On Thu, 13 May 2010 17:48:22 +0200, Martin Pohlack <mp26@os.inf.tu-dresden.de> wrote:
> 
> Hi,
> 
> interest in this problem was indicated to me in private mail, so let my
> sum up my findings so far.

[...]

> I use these two functions for computing the current target headline:

Thanks for these.  Useful to have a summary of the situation and your
solution is straightforward enough!

[-- Attachment #2: Type: text/plain, Size: 75 bytes --]

-- 
Eric S Fraga
GnuPG: 8F5C 279D 3907 E14A 5C29  570D C891 93D8 FFFC F67D

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Question: org-remember and level>1 target headline
  2010-05-13 15:48   ` Martin Pohlack
  2010-05-13 17:26     ` Eric S Fraga
@ 2010-05-14  3:42     ` Samuel Wales
  2010-05-15  6:42       ` Carsten Dominik
  1 sibling, 1 reply; 12+ messages in thread
From: Samuel Wales @ 2010-05-14  3:42 UTC (permalink / raw)
  To: Martin Pohlack; +Cc: org-mode

On 2010-05-13, Martin Pohlack <mp26@os.inf.tu-dresden.de> wrote:
> Is there interest to define remember targets via paths or via ID?

ID would be useful, I think.

-- 
Q: How many CDC "scientists" does it take to change a lightbulb?
A: "You only think it's dark." [CDC has denied a deadly disease for 25 years]
==========
Retrovirus: http://www.wpinstitute.org/xmrv/index.html

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

* Re: Question: org-remember and level>1 target headline
  2010-05-14  3:42     ` Samuel Wales
@ 2010-05-15  6:42       ` Carsten Dominik
  2010-05-18 17:39         ` Martin Pohlack
  2010-05-27  9:43         ` Question: org-remember and level>1 target headline [resent] Martin Pohlack
  0 siblings, 2 replies; 12+ messages in thread
From: Carsten Dominik @ 2010-05-15  6:42 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Martin Pohlack, org-mode


On May 14, 2010, at 5:42 AM, Samuel Wales wrote:

> On 2010-05-13, Martin Pohlack <mp26@os.inf.tu-dresden.de> wrote:
>> Is there interest to define remember targets via paths or via ID?
>
> ID would be useful, I think.

ID certainly - path could be useful to avoid ambiguities.

- Carsten

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

* Re: Question: org-remember and level>1 target headline
  2010-05-15  6:42       ` Carsten Dominik
@ 2010-05-18 17:39         ` Martin Pohlack
  2010-05-27  9:43         ` Question: org-remember and level>1 target headline [resent] Martin Pohlack
  1 sibling, 0 replies; 12+ messages in thread
From: Martin Pohlack @ 2010-05-18 17:39 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode

[-- Attachment #1: Type: text/plain, Size: 464 bytes --]

Hi,

On 15.05.2010 08:42, Carsten Dominik wrote:
> On May 14, 2010, at 5:42 AM, Samuel Wales wrote:
>> On 2010-05-13, Martin Pohlack<mp26@os.inf.tu-dresden.de>  wrote:
>>> Is there interest to define remember targets via paths or via ID?
>>
>> ID would be useful, I think.
>
> ID certainly - path could be useful to avoid ambiguities.

Please find attached a first version of a patch adding support for IDs
as remember targets.

Feedback welcome.

Cheers,
Martin


[-- Attachment #2: org-remember-id.diff --]
[-- Type: text/x-patch, Size: 2251 bytes --]

This patch adds support for specifying the ID of a target headline.

Open issues:
* Using a cons cell seems a bit ugly.  A string would be fine too but
  this is already used by the headline itself in the choice element.
* The visual appearance of the ID choice is suboptimal.  Is there any
  way to hide the const visually?
* The comments in the remember buffer seems to be setup wrong, where
  must I hook in to support IDs there?

diff --git a/home/mpohlack/src/org-mode/lisp/org-remember.el b/org-remember.el
index 59e015f..a0dbac4 100644
--- a/home/mpohlack/src/org-mode/lisp/org-remember.el
+++ b/org-remember.el
@@ -108,7 +108,8 @@ An optional fifth element can specify the headline in that file that should
 be offered first when the user is asked to file the entry.  The default
 headline is given in the variable `org-remember-default-headline'.  When
 this element is `top' or `bottom', the note will be placed as a level-1
-entry at the beginning or end of the file, respectively.
+entry at the beginning or end of the file, respectively.  You can also specify
+the `ID' of a target headline.
 
 An optional sixth element specifies the contexts in which the template
 will be offered to the user.  This element can be a list of major modes
@@ -195,7 +196,8 @@ calendar           |  %:type %:date"
 		 (const :tag "Use `org-remember-default-headline'" nil)
 		 (const :tag "At beginning of file" top)
 		 (const :tag "At end of file" bottom)
-		 (const :tag "In a date tree" date-tree))
+		 (const :tag "In a date tree" date-tree)
+                 (cons :tag "ID" (const :tag "" ID) (string :tag "ID")))
 		(choice :tag "Context"
 		 (const :tag "Use in all contexts" nil)
 		 (const :tag "Use in all contexts" t)
@@ -974,6 +976,10 @@ See also the variable `org-reverse-note-order'."
 		(org-datetree-find-date-create reference-date)
 		(setq reversed nil)
 		(setq org-goto-start-pos (point)))
+	       ((consp heading)
+		(setq org-goto-start-pos (org-find-entry-with-id (cdr heading)))
+                (when (not org-goto-start-pos)
+                  (error "Target headline with ID '%s' not found" (cdr heading))))
 	       ((and (stringp heading) (string-match "\\S-" heading))
 		(goto-char (point-min))
 		(if (re-search-forward


[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Question: org-remember and level>1 target headline [resent]
  2010-05-15  6:42       ` Carsten Dominik
  2010-05-18 17:39         ` Martin Pohlack
@ 2010-05-27  9:43         ` Martin Pohlack
  2010-06-22 12:54           ` Carsten Dominik
  1 sibling, 1 reply; 12+ messages in thread
From: Martin Pohlack @ 2010-05-27  9:43 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode

[-- Attachment #1: Type: text/plain, Size: 506 bytes --]

[resending to get into the patch tracker]

Hi,

On 15.05.2010 08:42, Carsten Dominik wrote:
> On May 14, 2010, at 5:42 AM, Samuel Wales wrote:
>> On 2010-05-13, Martin Pohlack<mp26@os.inf.tu-dresden.de>  wrote:
>>> Is there interest to define remember targets via paths or via ID?
>>
>> ID would be useful, I think.
>
> ID certainly - path could be useful to avoid ambiguities.

Please find attached a first version of a patch adding support for IDs
as remember targets.

Feedback welcome.

Cheers,
Martin

[-- Attachment #2: org-remember-id.diff --]
[-- Type: text/x-patch, Size: 2252 bytes --]

This patch adds support for specifying the ID of a target headline.

Open issues:
* Using a cons cell seems a bit ugly.  A string would be fine too but
  this is already used by the headline itself in the choice element.
* The visual appearance of the ID choice is suboptimal.  Is there any
  way to hide the const visually?
* The comments in the remember buffer seems to be setup wrong, where
  must I hook in to support IDs there?

diff --git a/home/mpohlack/src/org-mode/lisp/org-remember.el b/org-remember.el
index 59e015f..a0dbac4 100644
--- a/home/mpohlack/src/org-mode/lisp/org-remember.el
+++ b/org-remember.el
@@ -108,7 +108,8 @@ An optional fifth element can specify the headline in that file that should
 be offered first when the user is asked to file the entry.  The default
 headline is given in the variable `org-remember-default-headline'.  When
 this element is `top' or `bottom', the note will be placed as a level-1
-entry at the beginning or end of the file, respectively.
+entry at the beginning or end of the file, respectively.  You can also specify
+the `ID' of a target headline.
 
 An optional sixth element specifies the contexts in which the template
 will be offered to the user.  This element can be a list of major modes
@@ -195,7 +196,8 @@ calendar           |  %:type %:date"
 		 (const :tag "Use `org-remember-default-headline'" nil)
 		 (const :tag "At beginning of file" top)
 		 (const :tag "At end of file" bottom)
-		 (const :tag "In a date tree" date-tree))
+		 (const :tag "In a date tree" date-tree)
+                 (cons :tag "ID" (const :tag "" ID) (string :tag "ID")))
 		(choice :tag "Context"
 		 (const :tag "Use in all contexts" nil)
 		 (const :tag "Use in all contexts" t)
@@ -974,6 +976,10 @@ See also the variable `org-reverse-note-order'."
 		(org-datetree-find-date-create reference-date)
 		(setq reversed nil)
 		(setq org-goto-start-pos (point)))
+	       ((consp heading)
+		(setq org-goto-start-pos (org-find-entry-with-id (cdr heading)))
+                (when (not org-goto-start-pos)
+                  (error "Target headline with ID '%s' not found" (cdr heading))))
 	       ((and (stringp heading) (string-match "\\S-" heading))
 		(goto-char (point-min))
 		(if (re-search-forward



[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Question: org-remember and level>1 target headline [resent]
  2010-05-27  9:43         ` Question: org-remember and level>1 target headline [resent] Martin Pohlack
@ 2010-06-22 12:54           ` Carsten Dominik
  2010-06-22 13:38             ` Martin Pohlack
  0 siblings, 1 reply; 12+ messages in thread
From: Carsten Dominik @ 2010-06-22 12:54 UTC (permalink / raw)
  To: Martin Pohlack; +Cc: org-mode

Hi Martin,

I am rejecting this patch, but only because because I think this issue
is taken care of in org-capture.el   Let me know if you do not agree.

Cheers, and thanks for your contribution!

- Carsten

On May 27, 2010, at 11:43 AM, Martin Pohlack wrote:

> [resending to get into the patch tracker]
>
> Hi,
>
> On 15.05.2010 08:42, Carsten Dominik wrote:
>> On May 14, 2010, at 5:42 AM, Samuel Wales wrote:
>>> On 2010-05-13, Martin Pohlack<mp26@os.inf.tu-dresden.de>  wrote:
>>>> Is there interest to define remember targets via paths or via ID?
>>>
>>> ID would be useful, I think.
>>
>> ID certainly - path could be useful to avoid ambiguities.
>
> Please find attached a first version of a patch adding support for IDs
> as remember targets.
>
> Feedback welcome.
>
> Cheers,
> Martin
> <org-remember-id.diff>

- Carsten

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

* Re: Question: org-remember and level>1 target headline [resent]
  2010-06-22 12:54           ` Carsten Dominik
@ 2010-06-22 13:38             ` Martin Pohlack
  2010-06-22 13:43               ` Carsten Dominik
  2010-06-22 13:44               ` Martin Pohlack
  0 siblings, 2 replies; 12+ messages in thread
From: Martin Pohlack @ 2010-06-22 13:38 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode

On 22.06.2010 14:54, Carsten Dominik wrote:
> Hi Martin,
> 
> I am rejecting this patch, but only because because I think this issue
> is taken care of in org-capture.el   Let me know if you do not agree.

The documentation for outline path looks promising.  Even header paths
are supported -- nice!

Is there documentation for migrating from org-remember or will there be
once org-capture shows up in the manual?

Cheers,
Martin

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

* Re: Question: org-remember and level>1 target headline [resent]
  2010-06-22 13:38             ` Martin Pohlack
@ 2010-06-22 13:43               ` Carsten Dominik
  2010-06-22 13:44               ` Martin Pohlack
  1 sibling, 0 replies; 12+ messages in thread
From: Carsten Dominik @ 2010-06-22 13:43 UTC (permalink / raw)
  To: Martin Pohlack; +Cc: org-mode


On Jun 22, 2010, at 3:38 PM, Martin Pohlack wrote:

> On 22.06.2010 14:54, Carsten Dominik wrote:
>> Hi Martin,
>>
>> I am rejecting this patch, but only because because I think this  
>> issue
>> is taken care of in org-capture.el   Let me know if you do not agree.
>
> The documentation for outline path looks promising.  Even header paths
> are supported -- nice!
>
> Is there documentation for migrating from org-remember or will there  
> be
> once org-capture shows up in the manual?

Basically do

   M-x org-capture-import-remember-templates

then customize org-capture-templates to check and modify the setup,
and then use org-capture from now on to remember stuff.

Most of the documentation is (as I said in my mail) currently in the  
docstrings of the command org-capture and of the variable org-capture- 
templates.

Cheers

- Carsten

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

* Re: Question: org-remember and level>1 target headline [resent]
  2010-06-22 13:38             ` Martin Pohlack
  2010-06-22 13:43               ` Carsten Dominik
@ 2010-06-22 13:44               ` Martin Pohlack
  1 sibling, 0 replies; 12+ messages in thread
From: Martin Pohlack @ 2010-06-22 13:44 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode

On 22.06.2010 15:38, Martin Pohlack wrote:
> Is there documentation for migrating from org-remember or will there be
> once org-capture shows up in the manual?

Never mind the question, I just saw the exhaustive other mail describing
org-remember :-).

Cheers,
Martin

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

end of thread, other threads:[~2010-06-22 13:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-10 17:40 Question: org-remember and level>1 target headline Martin Pohlack
2010-05-11  9:18 ` Martin Pohlack
2010-05-13 15:48   ` Martin Pohlack
2010-05-13 17:26     ` Eric S Fraga
2010-05-14  3:42     ` Samuel Wales
2010-05-15  6:42       ` Carsten Dominik
2010-05-18 17:39         ` Martin Pohlack
2010-05-27  9:43         ` Question: org-remember and level>1 target headline [resent] Martin Pohlack
2010-06-22 12:54           ` Carsten Dominik
2010-06-22 13:38             ` Martin Pohlack
2010-06-22 13:43               ` Carsten Dominik
2010-06-22 13:44               ` Martin Pohlack

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).