emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Feature Request] org-mobile edit:add nodes
@ 2012-03-04 18:20 Henning Weiss
  2012-04-20 11:55 ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Henning Weiss @ 2012-03-04 18:20 UTC (permalink / raw)
  To: emacs-orgmode

Hi everyone,

I am currently trying to allow mobileorg-android to capture new
headings into files other than mobileorg.org. It seems to me that
org-mobile does not support refiling of nodes. As my experience with
lisp programming is very limited, I was hoping someone on this list
could add this feature.

I was thinking of something along the lines of an add edit node:

F(edit:add) [[node path to parent (olp or id)][Title]]
** Old value
** New value
*** TODO New node :tag1:tag2:
initial payload
** End of edit

Which would result in a new heading to be created under the parent
when org-mobile-apply is run. Having "delete nodes" would also be
great. Having those would make capturing much more convenient.

Everything to support this feature is added to mobileorg-android, it
simply needs to be extended to generate the appropriate "add edit
nodes".

Thanks in advance for any help,
Henning Weiss

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

* Re: [Feature Request] org-mobile edit:add nodes
  2012-03-04 18:20 [Feature Request] org-mobile edit:add nodes Henning Weiss
@ 2012-04-20 11:55 ` Bastien
  2012-04-23 18:25   ` Henning Weiss
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2012-04-20 11:55 UTC (permalink / raw)
  To: Henning Weiss; +Cc: emacs-orgmode

Hi Henning,

I'm not using org-mobile.el so it's hard to test this patch.

Can anyone test and report?

Henning Weiss <hdweiss@gmail.com> writes:

> I am currently trying to allow mobileorg-android to capture new
> headings into files other than mobileorg.org. It seems to me that
> org-mobile does not support refiling of nodes. As my experience with
> lisp programming is very limited, I was hoping someone on this list
> could add this feature.

-- 
 Bastien

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

* Re: [Feature Request] org-mobile edit:add nodes
  2012-04-20 11:55 ` Bastien
@ 2012-04-23 18:25   ` Henning Weiss
  2012-04-23 23:08     ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Henning Weiss @ 2012-04-23 18:25 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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

Hi Bastien,

it turns out that there are a couple of problems with that particular
patch. Some issues have already been fixed with the help of someone else
from the mobileorg community, but more work is required. As soon as it is
functional (and hopefully stable) I will post a new patch.

Henning

On Fri, Apr 20, 2012 at 1:55 PM, Bastien <bzg@altern.org> wrote:

> Hi Henning,
>
> I'm not using org-mobile.el so it's hard to test this patch.
>
> Can anyone test and report?
>
> Henning Weiss <hdweiss@gmail.com> writes:
>
> > I am currently trying to allow mobileorg-android to capture new
> > headings into files other than mobileorg.org. It seems to me that
> > org-mobile does not support refiling of nodes. As my experience with
> > lisp programming is very limited, I was hoping someone on this list
> > could add this feature.
>
> --
>  Bastien
>

[-- Attachment #2: Type: text/html, Size: 1534 bytes --]

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

* Re: [Feature Request] org-mobile edit:add nodes
  2012-04-23 18:25   ` Henning Weiss
@ 2012-04-23 23:08     ` Bastien
  2012-05-22 12:20       ` Henning Weiss
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2012-04-23 23:08 UTC (permalink / raw)
  To: Henning Weiss; +Cc: emacs-orgmode

Henning Weiss <hdweiss@gmail.com> writes:

> it turns out that there are a couple of problems with that particular
> patch. Some issues have already been fixed with the help of someone
> else from the mobileorg community, but more work is required. As soon
> as it is functional (and hopefully stable) I will post a new patch.

Please do -- thanks for the follow up!

-- 
 Bastien

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

* Re: [Feature Request] org-mobile edit:add nodes
  2012-04-23 23:08     ` Bastien
@ 2012-05-22 12:20       ` Henning Weiss
  2012-05-22 17:54         ` Bastien
  2012-07-05 15:47         ` Bastien
  0 siblings, 2 replies; 10+ messages in thread
From: Henning Weiss @ 2012-05-22 12:20 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 891 bytes --]

Hi,

On Tue, Apr 24, 2012 at 1:08 AM, Bastien <bzg@gnu.org> wrote:

> Henning Weiss <hdweiss@gmail.com> writes:
>
> > it turns out that there are a couple of problems with that particular
> > patch. Some issues have already been fixed with the help of someone
> > else from the mobileorg community, but more work is required. As soon
> > as it is functional (and hopefully stable) I will post a new patch.
>
> Please do -- thanks for the follow up!
>
> --
>  Bastien
>

I have refined the edit nodes patch. Aaron Peromsik has helped me with
developing and testing it. He hasn't reported any problems with it and I
have been using it for a couple of weeks now without experiencing any
problems.

According to the contribution guidelines this patch doesn't qualify as a
TINYCHANGE. Assuming this patch qualifies for inclusion, do I need to fill
out the FSF copyright assignment form?

Henning

[-- Attachment #1.2: Type: text/html, Size: 1362 bytes --]

[-- Attachment #2: 0001-org-mobile-Added-five-new-targets-for-edit-nodes.patch --]
[-- Type: application/octet-stream, Size: 7005 bytes --]

From daa86abebed7f5e1be4b6c2ec5027cb00694a98a Mon Sep 17 00:00:00 2001
From: Henning Weiss <hdweiss@gmail.com>
Date: Tue, 22 May 2012 13:32:27 +0200
Subject: [PATCH] org-mobile: Added five new targets for edit nodes

* lisp/org-mobile.el (org-mobile-edit): Added handling of
  addheading, refile, archive, archive-sibling and delete edit nodes.
(org-mobile-locate-entry): olp links containing only a file are now be
  located correctly.
(org-mobile-apply): Instead of finding the location of all target
  headings for edit nodes in a separate loop, they will be found
  immediately before applying edits.

org-mobile-apply needed to be changed, as the new edit nodes can
insert new headings or delete them, thereby changing the locations
of the target headings. Thanks to Aaron Peromsik for helping with
this patch.
---
 lisp/org-mobile.el |  104 +++++++++++++++++++++++++++++++++-------------------
 1 file changed, 67 insertions(+), 37 deletions(-)

diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el
index 946e821..82b2029 100644
--- a/lisp/org-mobile.el
+++ b/lisp/org-mobile.el
@@ -829,37 +829,16 @@ If BEG and END are given, only do this in that region."
 	   (not (equal (downcase (substring (match-string 1) 0 2)) "f("))
 	   (incf cnt-new)))
 
+    ;; Find and apply the edits
     (goto-char beg)
     (while (re-search-forward
 	    "^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)[ \t]+\\[\\[\\(\\(id\\|olp\\):\\([^]\n]+\\)\\)" end t)
-      (setq id-pos (condition-case msg
-		       (org-mobile-locate-entry (match-string 4))
-		     (error (nth 1 msg))))
-      (when (and (markerp id-pos)
-		 (not (member (marker-buffer id-pos) buf-list)))
-	(org-mobile-timestamp-buffer (marker-buffer id-pos))
-	(push (marker-buffer id-pos) buf-list))
-
-      (if (or (not id-pos) (stringp id-pos))
-	  (progn
-	    (goto-char (+ 2 (point-at-bol)))
-	    (insert id-pos " ")
-	    (incf cnt-error))
-	(add-text-properties (point-at-bol) (point-at-eol)
-			     (list 'org-mobile-marker
-				   (or id-pos "Linked entry not found")))))
-
-    ;; OK, now go back and start applying
-    (goto-char beg)
-    (while (re-search-forward "^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)" end t)
       (catch 'next
-	(setq id-pos (get-text-property (point-at-bol) 'org-mobile-marker))
-	(if (not (markerp id-pos))
-	    (progn
-	      (incf cnt-error)
-	      (insert "UNKNOWN PROBLEM"))
 	  (let* ((action (match-string 1))
 		 (data (and (match-end 3) (match-string 3)))
+		 (id-pos (condition-case msg
+			     (org-mobile-locate-entry (match-string 4))
+			   (error (nth 1 msg))))
 		 (bos (point-at-bol))
 		 (eos (save-excursion (org-end-of-subtree t t)))
 		 (cmd (if (equal action "")
@@ -874,7 +853,23 @@ If BEG and END are given, only do this in that region."
 			    (buffer-substring (1+ (point-at-eol)) eos)))
 		 (org-inhibit-logging 'note) ;; Do not take notes interactively
 		 old new)
+
 	    (goto-char bos)
+	    (when (and (markerp id-pos)
+		       (not (member (marker-buffer id-pos) buf-list)))
+	      (org-mobile-timestamp-buffer (marker-buffer id-pos))
+	      (push (marker-buffer id-pos) buf-list))
+	    (unless (markerp id-pos)
+	      (goto-char (+ 2 (point-at-bol)))
+	      (if (stringp id-pos)
+		  (insert id-pos " ")
+		(insert "BAD REFERENCE "))
+		(incf cnt-error)
+		(throw 'next t))
+	    (unless cmd
+	      (insert "BAD FLAG ")
+	      (incf cnt-error)
+	      (throw 'next t))
 	    (move-marker bos-marker (point))
 	    (if (re-search-forward "^** Old value[ \t]*$" eos t)
 		(setq old (buffer-substring
@@ -897,14 +892,6 @@ If BEG and END are given, only do this in that region."
 	      (setq new (and new (org-trim new))
 		    old (and old (org-trim old))))
 	    (goto-char (+ 2 bos-marker))
-	    (unless (markerp id-pos)
-	      (insert "BAD REFERENCE ")
-	      (incf cnt-error)
-	      (throw 'next t))
-	    (unless cmd
-	      (insert "BAD FLAG ")
-	      (incf cnt-error)
-	      (throw 'next t))
 	    ;; Remember this place so that we can return
 	    (move-marker marker (point))
 	    (setq org-mobile-error nil)
@@ -913,9 +900,10 @@ If BEG and END are given, only do this in that region."
 		  (org-with-point-at id-pos
 		    (progn
 		  (eval cmd)
-		  (if (member "FLAGGED" (org-get-tags))
+		  (unless (member data (list "delete" "archive" "archive-sibling" "addheading"))
+		    (if (member "FLAGGED" (org-get-tags))
 		      (add-to-list 'org-mobile-last-flagged-files
-				   (buffer-file-name (current-buffer))))))
+				   (buffer-file-name (current-buffer)))))))
 		(error (setq org-mobile-error msg))))
 	    (when org-mobile-error
 	      (org-pop-to-buffer-same-window (marker-buffer marker))
@@ -929,7 +917,7 @@ If BEG and END are given, only do this in that region."
 	    ;; If we get here, the action has been applied successfully
 	    ;; So remove the entry
 	    (goto-char bos-marker)
-	    (delete-region (point) (org-end-of-subtree t t))))))
+	    (delete-region (point) (org-end-of-subtree t t)))))
     (save-buffer)
     (move-marker marker nil)
     (move-marker end nil)
@@ -990,7 +978,19 @@ is currently a noop.")
   (if (string-match "\\`id:\\(.*\\)$" link)
       (org-id-find (match-string 1 link) 'marker)
     (if (not (string-match "\\`olp:\\(.*?\\):\\(.*\\)$" link))
-	nil
+	; not found with path, but maybe it is to be inserted
+	; in top level of the file?
+	(if (not (string-match "\\`olp:\\(.*?\\)$" link))
+	    nil
+	  (let ((file (match-string 1 link)))
+	    (setq file (org-link-unescape file))
+	    (setq file (expand-file-name file org-directory))
+	    (save-excursion
+	      (find-file file)
+	      (goto-char (point-max))
+	      (newline)
+	      (goto-char (point-max))
+	      (move-marker (make-marker) (point)))))
       (let ((file (match-string 1 link))
 	    (path (match-string 2 link)))
 	(setq file (org-link-unescape file))
@@ -1064,6 +1064,36 @@ be returned that indicates what went wrong."
 	  (org-set-tags nil 'align))
 	 (t (error "Heading changed in MobileOrg and on the computer")))))
 
+     ((eq what 'addheading)
+      (if (org-on-heading-p) ; if false we are in top-level of file
+	  (progn
+	    (end-of-line 1)
+	    (org-insert-heading-respect-content)
+	    (org-demote))
+	(beginning-of-line)
+	(insert "* "))
+      (insert new))
+
+     ((eq what 'refile)
+      (org-copy-subtree)
+      (org-with-point-at (org-mobile-locate-entry new)
+	(if (org-on-heading-p) ; if false we are in top-level of file
+	    (progn
+	      (setq level (org-get-valid-level (funcall outline-level) 1))
+	      (org-end-of-subtree t t)
+	      (org-paste-subtree level))
+	(org-paste-subtree 1)))
+	(org-cut-subtree))
+
+     ((eq what 'delete)
+      (org-cut-subtree))
+
+     ((eq what 'archive)
+      (org-archive-subtree))
+
+     ((eq what 'archive-sibling)
+      (org-archive-to-archive-sibling))
+
      ((eq what 'body)
       (setq current (buffer-substring (min (1+ (point-at-eol)) (point-max))
 				      (save-excursion (outline-next-heading)
-- 
1.7.10


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

* Re: [Feature Request] org-mobile edit:add nodes
  2012-05-22 12:20       ` Henning Weiss
@ 2012-05-22 17:54         ` Bastien
  2012-05-23  0:09           ` Henning Weiss
  2012-07-05 15:47         ` Bastien
  1 sibling, 1 reply; 10+ messages in thread
From: Bastien @ 2012-05-22 17:54 UTC (permalink / raw)
  To: Henning Weiss; +Cc: emacs-orgmode

Hi Henning,

Henning Weiss <hdweiss@gmail.com> writes:

> I have refined the edit nodes patch. Aaron Peromsik has helped me
> with developing and testing it. He hasn't reported any problems with
> it and I have been using it for a couple of weeks now without
> experiencing any problems.

Thanks.  Can someone else test this patch?  I'm not using org-mobile.el.

> According to the contribution guidelines this patch doesn't qualify
> as a TINYCHANGE. Assuming this patch qualifies for inclusion, do I
> need to fill out the FSF copyright assignment form?

Yes, please do so.

Thanks,

-- 
 Bastien

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

* Re: [Feature Request] org-mobile edit:add nodes
  2012-05-22 17:54         ` Bastien
@ 2012-05-23  0:09           ` Henning Weiss
  2012-06-21  4:11             ` Aaron Peromsik
  0 siblings, 1 reply; 10+ messages in thread
From: Henning Weiss @ 2012-05-23  0:09 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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

On Tue, May 22, 2012 at 7:54 PM, Bastien <bzg@gnu.org> wrote:

> Hi Henning,
>
> Henning Weiss <hdweiss@gmail.com> writes:
>
> > I have refined the edit nodes patch. Aaron Peromsik has helped me
> > with developing and testing it. He hasn't reported any problems with
> > it and I have been using it for a couple of weeks now without
> > experiencing any problems.
>
> Thanks.  Can someone else test this patch?  I'm not using org-mobile.el.


To make the testing of the new edit nodes more attractive, someone could
compile the new editnodes
branch<https://github.com/matburt/mobileorg-android/tree/editnodes>from
mobileorg-android. This branch adds support for refiling, deleting and
archiving nodes. Further explanation can be found
here<https://groups.google.com/forum/?fromgroups#!topic/mobileorg-android/4Hzp51gK38I>
.

Henning

[-- Attachment #2: Type: text/html, Size: 1253 bytes --]

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

* Re: [Feature Request] org-mobile edit:add nodes
  2012-05-23  0:09           ` Henning Weiss
@ 2012-06-21  4:11             ` Aaron Peromsik
  2012-06-22 18:24               ` Henning Weiss
  0 siblings, 1 reply; 10+ messages in thread
From: Aaron Peromsik @ 2012-06-21  4:11 UTC (permalink / raw)
  To: emacs-orgmode

Henning Weiss <hdweiss <at> gmail.com> writes:

> 
> 
> On Tue, May 22, 2012 at 7:54 PM, Bastien <bzg <at> gnu.org> wrote:
> 
> 
> Hi Henning,
> 
> Henning Weiss <hdweiss <at> gmail.com> writes:
> > I have refined the edit nodes patch. Aaron Peromsik has helped me
> > with developing and testing it. He hasn't reported any problems with
> > it and I have been using it for a couple of weeks now without
> > experiencing any problems.
> Thanks.  Can someone else test this patch?  I'm not using org-mobile.el.
> 
> To make the testing of the new edit nodes more attractive, someone could 
compile the new editnodes branch from mobileorg-android. This branch adds 
support for refiling, deleting and archiving nodes. Further explanation can be 
found here.
> 
> Henning
> 
> 

For what it's worth, I have continued using the editnodes branch of mobileorg 
for Android along with Henning's editnodes patches for org-mode, and I have not 
had trouble with adding, deleting, or editing nodes. (Though as I have 
mentioned, it would be nice if there were a way to configure it to put new nodes 
at the top of the nodes at a given level instead of the bottom.)

-- Aaron

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

* Re: [Feature Request] org-mobile edit:add nodes
  2012-06-21  4:11             ` Aaron Peromsik
@ 2012-06-22 18:24               ` Henning Weiss
  0 siblings, 0 replies; 10+ messages in thread
From: Henning Weiss @ 2012-06-22 18:24 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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

Hi Bastien,

both Aaron and me have used this patch for a while now without problems.
What would it take to get it merged in?

Henning

[-- Attachment #2: Type: text/html, Size: 176 bytes --]

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

* Re: [Feature Request] org-mobile edit:add nodes
  2012-05-22 12:20       ` Henning Weiss
  2012-05-22 17:54         ` Bastien
@ 2012-07-05 15:47         ` Bastien
  1 sibling, 0 replies; 10+ messages in thread
From: Bastien @ 2012-07-05 15:47 UTC (permalink / raw)
  To: Henning Weiss; +Cc: emacs-orgmode

Hi Henning,

Henning Weiss <hdweiss@gmail.com> writes:

> I have refined the edit nodes patch. Aaron Peromsik has helped me
> with developing and testing it. He hasn't reported any problems with
> it and I have been using it for a couple of weeks now without
> experiencing any problems.

I applied this patch now.  Thanks for your patience!

-- 
 Bastien

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

end of thread, other threads:[~2012-07-05 15:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-04 18:20 [Feature Request] org-mobile edit:add nodes Henning Weiss
2012-04-20 11:55 ` Bastien
2012-04-23 18:25   ` Henning Weiss
2012-04-23 23:08     ` Bastien
2012-05-22 12:20       ` Henning Weiss
2012-05-22 17:54         ` Bastien
2012-05-23  0:09           ` Henning Weiss
2012-06-21  4:11             ` Aaron Peromsik
2012-06-22 18:24               ` Henning Weiss
2012-07-05 15:47         ` Bastien

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