emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-at-property-p and related
@ 2010-03-11 12:49 Mikael Fornius
  2010-03-11 12:52 ` Mikael Fornius
  0 siblings, 1 reply; 10+ messages in thread
From: Mikael Fornius @ 2010-03-11 12:49 UTC (permalink / raw)
  To: emacs-orgmode

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


I am suggesting some changes to org-at-property-p (using
org-get-property-block) and making related procedures take advantage of
it.

* org.el (org-at-property-p): Check if we are inside a property
  drawer not just any drawer.

  (org-set-property, org-delete-property): When cursor is on a
  property key value pair do not prompt for property name instead
  use name at cursor.

(COMMENT: I did not adapt the delete all properties function to use
property under cursor directly because maybe you need to think twice
before that kind of operation.)
  
  (org-ctrl-c-ctrl-c): Still do org-property-action when cursor is
  on the first line of a property drawer.
  (org-property-end-re): Spell check.


  
I have set up a git-repository with a branch named 'mfo' with these
changes. If you like it please use it in org-mode and try to pull the
changes from

git://git.abc.se/mfo/git/org-mode

branch 'mfo'. I am new to this so I am not sure if it works to pull. I
have tried it myself but I am a little confused over the setup with
--bare repository, HEADs, branches and all.

Therefore I also attach the patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-at-property-p --]
[-- Type: text/x-patch, Size: 4795 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d6a0f76..6d30f08 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,14 +1,3 @@
-2010-03-11  Mikael Fornius  <mfo@abc.se>
-
-	* org.el (org-at-property-p): Check if we are inside a property
-	drawer not just any drawer.
-	(org-set-property, org-delete-property): When cursor is on a
-	property key value pair do not prompt for property name instead
-	use name at cursor.
-	(org-ctrl-c-ctrl-c): Still do org-property-action when cursor is
-	on the first line of a property drawer.
-	(org-property-end-re): Spell check.
-
 2010-03-11  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-exp.el (org-export-attach-captions-and-attributes): Add the
diff --git a/lisp/org.el b/lisp/org.el
index ad15d5e..463ae46 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12469,7 +12469,7 @@ Being in this list makes sure that they are offered for completion.")
   "Regular expression matching the first line of a property drawer.")
 
 (defconst org-property-end-re "^[ \t]*:END:[ \t]*$"
-  "Regular expression matching the last line of a property drawer.")
+  "Regular expression matching the first line of a property drawer.")
 
 (defconst org-clock-drawer-start-re "^[ \t]*:CLOCK:[ \t]*$"
   "Regular expression matching the first line of a property drawer.")
@@ -12546,16 +12546,13 @@ allowed value."
     (message "%s is now %s" prop val)))
 
 (defun org-at-property-p ()
-  "Is cursor inside a property drawer?"
+  "Is the cursor in a property line?"
+  ;; FIXME: Does not check if we are actually in the drawer.
+  ;; FIXME: also returns true on any drawers.....
+  ;; This is used by C-c C-c for property action.
   (save-excursion
     (beginning-of-line 1)
-    (when (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))
-     (let ((match (match-data)) ;; Keep match-data for use by calling
-	   (p (point))          ;; procedures.
-	   (range (unless (org-before-first-heading-p)
-		    (org-get-property-block))))
-       (prog1 (and range (<= (car range) p) (< p (cdr range)))
-	 (set-match-data match))))))
+    (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))))
 
 (defun org-get-property-block (&optional beg end force)
   "Return the (beg . end) range of the body of the property drawer.
@@ -12986,8 +12983,7 @@ in the current file."
   (interactive
    (let* ((completion-ignore-case t)
 	  (keys (org-buffer-property-keys nil t t))
-	  (prop0 (or (progn (org-at-property-p) (org-match-string-no-properties 2))
-		     (org-icompleting-read "Property: " (mapcar 'list keys))))
+	  (prop0 (org-icompleting-read "Property: " (mapcar 'list keys)))
 	  (prop (if (member prop0 keys)
 		    prop0
 		  (or (cdr (assoc (downcase prop0)
@@ -12995,17 +12991,18 @@ in the current file."
 					  keys)))
 		      prop0)))
 	  (cur (org-entry-get nil prop))
-	  (prompt (concat prop " value"
-			  (if (and cur (string-match "\\S-" cur))
-			      (concat " [" cur "]") "") ": "))
 	  (allowed (org-property-get-allowed-values nil prop 'table))
 	  (existing (mapcar 'list (org-property-values prop)))
 	  (val (if allowed
-		   (org-completing-read prompt allowed nil
+		   (org-completing-read "Value: " allowed nil
 		      (not (get-text-property 0 'org-unrestricted
 					      (caar allowed))))
 		 (let (org-completion-use-ido org-completion-use-iswitchb)
-		   (org-completing-read prompt existing nil nil "" nil cur)))))
+		   (org-completing-read
+		    (concat "Value" (if (and cur (string-match "\\S-" cur))
+					(concat " [" cur "]") "")
+			    ": ")
+		    existing nil nil "" nil cur)))))
      (list prop (if (equal val "") cur val))))
   (unless (equal (org-entry-get nil property) value)
     (org-entry-put nil property value)))
@@ -13014,9 +13011,8 @@ in the current file."
   "In the current entry, delete PROPERTY."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (or (progn (org-at-property-p) (org-match-string-no-properties 2))
-		    (org-icompleting-read
-		     "Property: " (org-entry-properties nil 'standard)))))
+	  (prop (org-icompleting-read
+		 "Property: " (org-entry-properties nil 'standard))))
      (list prop)))
   (message "Property %s %s" property
 	   (if (org-entry-delete nil property)
@@ -16014,8 +16010,7 @@ This command does many different things, depending on context:
 	   (fboundp org-finish-function))
       (funcall org-finish-function))
      ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
-     ((or (looking-at (org-re org-property-start-re))
-	  (org-at-property-p))
+     ((org-at-property-p)
       (call-interactively 'org-property-action))
      ((org-on-target-p) (call-interactively 'org-update-radio-target-regexp))
      ((and (org-in-regexp "\\[\\([0-9]*%\\|[0-9]*/[0-9]*\\)\\]")

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



Org-mode is great!

-- 
Mikael Fornius

[-- Attachment #4: 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] 10+ messages in thread

* Re: [PATCH] org-at-property-p and related
  2010-03-11 12:49 [PATCH] org-at-property-p and related Mikael Fornius
@ 2010-03-11 12:52 ` Mikael Fornius
  2010-03-11 13:06   ` Mikael Fornius
  0 siblings, 1 reply; 10+ messages in thread
From: Mikael Fornius @ 2010-03-11 12:52 UTC (permalink / raw)
  To: emacs-orgmode

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


Sorry the attached patch is inverted! :-)

Try this.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: For real? --]
[-- Type: text/x-patch, Size: 4845 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5aece42..e9d7065 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
+2010-03-06  Mikael Fornius  <mfo@abc.se>
+
+	* org.el (org-set-property, org-delete-property): When cursor is
+	on a property key value pair do not prompt for property name
+	instead use name at cursor.
+	(org-ctrl-c-ctrl-c): Still do org-property-action when cursor is
+	on the first line of a property drawer.
+
+2010-03-05  Mikael Fornius  <mfo@abc.se>
+
+	* org.el (org-at-property-p): Check if we are inside a property
+	drawer not just any drawer.
+	(org-property-end-re): Spell check.
+
 2010-03-01  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-list.el (org-toggle-checkbox): No errors when updating
diff --git a/lisp/org.el b/lisp/org.el
index fd906f0..ba0c739 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12435,7 +12435,7 @@ Being in this list makes sure that they are offered for completion.")
   "Regular expression matching the first line of a property drawer.")
 
 (defconst org-property-end-re "^[ \t]*:END:[ \t]*$"
-  "Regular expression matching the first line of a property drawer.")
+  "Regular expression matching the last line of a property drawer.")
 
 (defconst org-clock-drawer-start-re "^[ \t]*:CLOCK:[ \t]*$"
   "Regular expression matching the first line of a property drawer.")
@@ -12512,13 +12512,16 @@ allowed value."
     (message "%s is now %s" prop val)))
 
 (defun org-at-property-p ()
-  "Is the cursor in a property line?"
-  ;; FIXME: Does not check if we are actually in the drawer.
-  ;; FIXME: also returns true on any drawers.....
-  ;; This is used by C-c C-c for property action.
+  "Is cursor inside a property drawer?"
   (save-excursion
     (beginning-of-line 1)
-    (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))))
+    (when (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))
+     (let ((match (match-data)) ;; Keep match-data for use by calling
+	   (p (point))          ;; procedures.
+	   (range (unless (org-before-first-heading-p)
+		    (org-get-property-block))))
+       (prog1 (and range (<= (car range) p) (< p (cdr range)))
+	 (set-match-data match))))))
 
 (defun org-get-property-block (&optional beg end force)
   "Return the (beg . end) range of the body of the property drawer.
@@ -12949,7 +12952,8 @@ in the current file."
   (interactive
    (let* ((completion-ignore-case t)
 	  (keys (org-buffer-property-keys nil t t))
-	  (prop0 (org-icompleting-read "Property: " (mapcar 'list keys)))
+	  (prop0 (or (progn (org-at-property-p) (org-match-string-no-properties 2))
+		     (org-icompleting-read "Property: " (mapcar 'list keys))))
 	  (prop (if (member prop0 keys)
 		    prop0
 		  (or (cdr (assoc (downcase prop0)
@@ -12957,18 +12961,17 @@ in the current file."
 					  keys)))
 		      prop0)))
 	  (cur (org-entry-get nil prop))
+	  (prompt (concat prop " value"
+			  (if (and cur (string-match "\\S-" cur))
+			      (concat " [" cur "]") "") ": "))
 	  (allowed (org-property-get-allowed-values nil prop 'table))
 	  (existing (mapcar 'list (org-property-values prop)))
 	  (val (if allowed
-		   (org-completing-read "Value: " allowed nil
+		   (org-completing-read prompt allowed nil
 		      (not (get-text-property 0 'org-unrestricted
 					      (caar allowed))))
 		 (let (org-completion-use-ido org-completion-use-iswitchb)
-		   (org-completing-read
-		    (concat "Value" (if (and cur (string-match "\\S-" cur))
-					(concat " [" cur "]") "")
-			    ": ")
-		    existing nil nil "" nil cur)))))
+		   (org-completing-read prompt existing nil nil "" nil cur)))))
      (list prop (if (equal val "") cur val))))
   (unless (equal (org-entry-get nil property) value)
     (org-entry-put nil property value)))
@@ -12977,8 +12980,9 @@ in the current file."
   "In the current entry, delete PROPERTY."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (org-icompleting-read
-		 "Property: " (org-entry-properties nil 'standard))))
+	  (prop (or (progn (org-at-property-p) (org-match-string-no-properties 2))
+		    (org-icompleting-read
+		     "Property: " (org-entry-properties nil 'standard)))))
      (list prop)))
   (message "Property %s %s" property
 	   (if (org-entry-delete nil property)
@@ -15976,7 +15980,8 @@ This command does many different things, depending on context:
 	   (fboundp org-finish-function))
       (funcall org-finish-function))
      ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
-     ((org-at-property-p)
+     ((or (looking-at (org-re org-property-start-re))
+	  (org-at-property-p))
       (call-interactively 'org-property-action))
      ((org-on-target-p) (call-interactively 'org-update-radio-target-regexp))
      ((and (org-in-regexp "\\[\\([0-9]*%\\|[0-9]*/[0-9]*\\)\\]")

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


-- 
Mikael Fornius

[-- Attachment #4: 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] 10+ messages in thread

* Re: [PATCH] org-at-property-p and related
  2010-03-11 12:52 ` Mikael Fornius
@ 2010-03-11 13:06   ` Mikael Fornius
  2010-03-11 13:10     ` Carsten Dominik
  0 siblings, 1 reply; 10+ messages in thread
From: Mikael Fornius @ 2010-03-11 13:06 UTC (permalink / raw)
  To: emacs-orgmode

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


Oh man! That was old.

Sorry. Third attempt:

This is the one:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: here --]
[-- Type: text/x-patch, Size: 4795 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6d30f08..d6a0f76 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
+2010-03-11  Mikael Fornius  <mfo@abc.se>
+
+	* org.el (org-at-property-p): Check if we are inside a property
+	drawer not just any drawer.
+	(org-set-property, org-delete-property): When cursor is on a
+	property key value pair do not prompt for property name instead
+	use name at cursor.
+	(org-ctrl-c-ctrl-c): Still do org-property-action when cursor is
+	on the first line of a property drawer.
+	(org-property-end-re): Spell check.
+
 2010-03-11  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-exp.el (org-export-attach-captions-and-attributes): Add the
diff --git a/lisp/org.el b/lisp/org.el
index 463ae46..ad15d5e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12469,7 +12469,7 @@ Being in this list makes sure that they are offered for completion.")
   "Regular expression matching the first line of a property drawer.")
 
 (defconst org-property-end-re "^[ \t]*:END:[ \t]*$"
-  "Regular expression matching the first line of a property drawer.")
+  "Regular expression matching the last line of a property drawer.")
 
 (defconst org-clock-drawer-start-re "^[ \t]*:CLOCK:[ \t]*$"
   "Regular expression matching the first line of a property drawer.")
@@ -12546,13 +12546,16 @@ allowed value."
     (message "%s is now %s" prop val)))
 
 (defun org-at-property-p ()
-  "Is the cursor in a property line?"
-  ;; FIXME: Does not check if we are actually in the drawer.
-  ;; FIXME: also returns true on any drawers.....
-  ;; This is used by C-c C-c for property action.
+  "Is cursor inside a property drawer?"
   (save-excursion
     (beginning-of-line 1)
-    (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))))
+    (when (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))
+     (let ((match (match-data)) ;; Keep match-data for use by calling
+	   (p (point))          ;; procedures.
+	   (range (unless (org-before-first-heading-p)
+		    (org-get-property-block))))
+       (prog1 (and range (<= (car range) p) (< p (cdr range)))
+	 (set-match-data match))))))
 
 (defun org-get-property-block (&optional beg end force)
   "Return the (beg . end) range of the body of the property drawer.
@@ -12983,7 +12986,8 @@ in the current file."
   (interactive
    (let* ((completion-ignore-case t)
 	  (keys (org-buffer-property-keys nil t t))
-	  (prop0 (org-icompleting-read "Property: " (mapcar 'list keys)))
+	  (prop0 (or (progn (org-at-property-p) (org-match-string-no-properties 2))
+		     (org-icompleting-read "Property: " (mapcar 'list keys))))
 	  (prop (if (member prop0 keys)
 		    prop0
 		  (or (cdr (assoc (downcase prop0)
@@ -12991,18 +12995,17 @@ in the current file."
 					  keys)))
 		      prop0)))
 	  (cur (org-entry-get nil prop))
+	  (prompt (concat prop " value"
+			  (if (and cur (string-match "\\S-" cur))
+			      (concat " [" cur "]") "") ": "))
 	  (allowed (org-property-get-allowed-values nil prop 'table))
 	  (existing (mapcar 'list (org-property-values prop)))
 	  (val (if allowed
-		   (org-completing-read "Value: " allowed nil
+		   (org-completing-read prompt allowed nil
 		      (not (get-text-property 0 'org-unrestricted
 					      (caar allowed))))
 		 (let (org-completion-use-ido org-completion-use-iswitchb)
-		   (org-completing-read
-		    (concat "Value" (if (and cur (string-match "\\S-" cur))
-					(concat " [" cur "]") "")
-			    ": ")
-		    existing nil nil "" nil cur)))))
+		   (org-completing-read prompt existing nil nil "" nil cur)))))
      (list prop (if (equal val "") cur val))))
   (unless (equal (org-entry-get nil property) value)
     (org-entry-put nil property value)))
@@ -13011,8 +13014,9 @@ in the current file."
   "In the current entry, delete PROPERTY."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (org-icompleting-read
-		 "Property: " (org-entry-properties nil 'standard))))
+	  (prop (or (progn (org-at-property-p) (org-match-string-no-properties 2))
+		    (org-icompleting-read
+		     "Property: " (org-entry-properties nil 'standard)))))
      (list prop)))
   (message "Property %s %s" property
 	   (if (org-entry-delete nil property)
@@ -16010,7 +16014,8 @@ This command does many different things, depending on context:
 	   (fboundp org-finish-function))
       (funcall org-finish-function))
      ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
-     ((org-at-property-p)
+     ((or (looking-at (org-re org-property-start-re))
+	  (org-at-property-p))
       (call-interactively 'org-property-action))
      ((org-on-target-p) (call-interactively 'org-update-radio-target-regexp))
      ((and (org-in-regexp "\\[\\([0-9]*%\\|[0-9]*/[0-9]*\\)\\]")

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


-- 
Mikael Fornius

[-- Attachment #4: 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] 10+ messages in thread

* Re: Re: [PATCH] org-at-property-p and related
  2010-03-11 13:06   ` Mikael Fornius
@ 2010-03-11 13:10     ` Carsten Dominik
  2010-03-11 14:01       ` Mikael Fornius
  0 siblings, 1 reply; 10+ messages in thread
From: Carsten Dominik @ 2010-03-11 13:10 UTC (permalink / raw)
  To: Mikael Fornius; +Cc: emacs-orgmode

Applied, thanks!

- Carsten

On Mar 11, 2010, at 2:06 PM, Mikael Fornius wrote:

>
> Oh man! That was old.
>
> Sorry. Third attempt:
>
> This is the one:
>
> <org-at-property-p-2.diff>
> -- 
> Mikael Fornius
> _______________________________________________
> 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

- Carsten

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

* Re: [PATCH] org-at-property-p and related
  2010-03-11 13:10     ` Carsten Dominik
@ 2010-03-11 14:01       ` Mikael Fornius
  2010-03-11 14:05         ` Carsten Dominik
  0 siblings, 1 reply; 10+ messages in thread
From: Mikael Fornius @ 2010-03-11 14:01 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

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


Sorry, I did a little wrong again. It is not my day today...

Please also apply this for correct behavior:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 2 progn -> when --]
[-- Type: text/x-patch, Size: 927 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index ad15d5e..a4932a2 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12986,7 +12986,7 @@ in the current file."
   (interactive
    (let* ((completion-ignore-case t)
 	  (keys (org-buffer-property-keys nil t t))
-	  (prop0 (or (progn (org-at-property-p) (org-match-string-no-properties 2))
+	  (prop0 (or (when (org-at-property-p) (org-match-string-no-properties 2))
 		     (org-icompleting-read "Property: " (mapcar 'list keys))))
 	  (prop (if (member prop0 keys)
 		    prop0
@@ -13014,7 +13014,7 @@ in the current file."
   "In the current entry, delete PROPERTY."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (or (progn (org-at-property-p) (org-match-string-no-properties 2))
+	  (prop (or (when (org-at-property-p) (org-match-string-no-properties 2))
 		    (org-icompleting-read
 		     "Property: " (org-entry-properties nil 'standard)))))
      (list prop)))

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


-- 
Mikael Fornius

[-- Attachment #4: 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] 10+ messages in thread

* Re: [PATCH] org-at-property-p and related
  2010-03-11 14:01       ` Mikael Fornius
@ 2010-03-11 14:05         ` Carsten Dominik
  2010-03-11 16:43           ` [PATCH] org-set/delete-property Mikael Fornius
  0 siblings, 1 reply; 10+ messages in thread
From: Carsten Dominik @ 2010-03-11 14:05 UTC (permalink / raw)
  To: Mikael Fornius; +Cc: emacs-orgmode

Done, thanks...

- Carsten

On Mar 11, 2010, at 3:01 PM, Mikael Fornius wrote:

>
> Sorry, I did a little wrong again. It is not my day today...
>
> Please also apply this for correct behavior:
>
> diff --git a/lisp/org.el b/lisp/org.el
> index ad15d5e..a4932a2 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -12986,7 +12986,7 @@ in the current file."
>   (interactive
>    (let* ((completion-ignore-case t)
> 	  (keys (org-buffer-property-keys nil t t))
> -	  (prop0 (or (progn (org-at-property-p) (org-match-string-no- 
> properties 2))
> +	  (prop0 (or (when (org-at-property-p) (org-match-string-no- 
> properties 2))
> 		     (org-icompleting-read "Property: " (mapcar 'list keys))))
> 	  (prop (if (member prop0 keys)
> 		    prop0
> @@ -13014,7 +13014,7 @@ in the current file."
>   "In the current entry, delete PROPERTY."
>   (interactive
>    (let* ((completion-ignore-case t)
> -	  (prop (or (progn (org-at-property-p) (org-match-string-no- 
> properties 2))
> +	  (prop (or (when (org-at-property-p) (org-match-string-no- 
> properties 2))
> 		    (org-icompleting-read
> 		     "Property: " (org-entry-properties nil 'standard)))))
>      (list prop)))
>
> -- 
> Mikael Fornius

- Carsten

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

* Re: [PATCH] org-set/delete-property
  2010-03-11 14:05         ` Carsten Dominik
@ 2010-03-11 16:43           ` Mikael Fornius
  2010-03-12 16:38             ` Carsten Dominik
  0 siblings, 1 reply; 10+ messages in thread
From: Mikael Fornius @ 2010-03-11 16:43 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

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


Hmm... I realize I should have thought some more about this before
posting the original patch.

I have second thoughts:

I think the behavior to take property under cursor as the one intended
to change when editing properties feels forcing and may be confusing.

Therefore I suggest two alternatives:

make it default alternative


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Property under cursor as INITIAL-INPUT in completing-read. --]
[-- Type: text/x-patch, Size: 2372 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d6a0f76..425be41 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,13 @@
 2010-03-11  Mikael Fornius  <mfo@abc.se>
 
+	* org.el (org-set-property, org-delete-property)
+	(org-delete-property-globally): Suggest property at cursor as
+	initial input in completing-read instead of taking it as chosen.
+	For a more natural behavior. (Initial input does not work with
+	iswtichb.)
+
+2010-03-11  Mikael Fornius  <mfo@abc.se>
+
 	* org.el (org-at-property-p): Check if we are inside a property
 	drawer not just any drawer.
 	(org-set-property, org-delete-property): When cursor is on a
diff --git a/lisp/org.el b/lisp/org.el
index a4932a2..0ba61fe 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12986,8 +12986,8 @@ in the current file."
   (interactive
    (let* ((completion-ignore-case t)
 	  (keys (org-buffer-property-keys nil t t))
-	  (prop0 (or (when (org-at-property-p) (org-match-string-no-properties 2))
-		     (org-icompleting-read "Property: " (mapcar 'list keys))))
+	  (prop0 (org-icompleting-read "Property: " (mapcar 'list keys) nil nil
+				       (when (org-at-property-p) (org-match-string-no-properties 2))))
 	  (prop (if (member prop0 keys)
 		    prop0
 		  (or (cdr (assoc (downcase prop0)
@@ -13014,9 +13014,8 @@ in the current file."
   "In the current entry, delete PROPERTY."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (or (when (org-at-property-p) (org-match-string-no-properties 2))
-		    (org-icompleting-read
-		     "Property: " (org-entry-properties nil 'standard)))))
+	  (prop (org-icompleting-read "Property: " (org-entry-properties nil 'standard) nil nil
+				      (when (org-at-property-p) (org-match-string-no-properties 2)))))
      (list prop)))
   (message "Property %s %s" property
 	   (if (org-entry-delete nil property)
@@ -13027,9 +13026,9 @@ in the current file."
   "Remove PROPERTY globally, from all entries."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (org-icompleting-read
-		 "Globally remove property: "
-		 (mapcar 'list (org-buffer-property-keys)))))
+	  (prop (org-icompleting-read "Globally remove property: "
+				      (mapcar 'list (org-buffer-property-keys))  nil nil
+				      (when (org-at-property-p) (org-match-string-no-properties 2)))))
      (list prop)))
   (save-excursion
     (save-restriction

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


or always prompt (like before)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: Always prompt for property to operate on. (Old behavior.) --]
[-- Type: text/x-patch, Size: 1555 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d6a0f76..4c4aac7 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
 2010-03-11  Mikael Fornius  <mfo@abc.se>
 
+	* org.el (org-set-property, org-delete-property): Reverted to old
+	behaviour: do not use property at cursor but prompt always.
+
+2010-03-11  Mikael Fornius  <mfo@abc.se>
+
 	* org.el (org-at-property-p): Check if we are inside a property
 	drawer not just any drawer.
 	(org-set-property, org-delete-property): When cursor is on a
diff --git a/lisp/org.el b/lisp/org.el
index a4932a2..72dfa9d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12986,8 +12986,7 @@ in the current file."
   (interactive
    (let* ((completion-ignore-case t)
 	  (keys (org-buffer-property-keys nil t t))
-	  (prop0 (or (when (org-at-property-p) (org-match-string-no-properties 2))
-		     (org-icompleting-read "Property: " (mapcar 'list keys))))
+	  (prop0 (org-icompleting-read "Property: " (mapcar 'list keys)))
 	  (prop (if (member prop0 keys)
 		    prop0
 		  (or (cdr (assoc (downcase prop0)
@@ -13014,9 +13013,7 @@ in the current file."
   "In the current entry, delete PROPERTY."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (or (when (org-at-property-p) (org-match-string-no-properties 2))
-		    (org-icompleting-read
-		     "Property: " (org-entry-properties nil 'standard)))))
+	  (prop (org-icompleting-read "Property: " (org-entry-properties nil 'standard))))
      (list prop)))
   (message "Property %s %s" property
 	   (if (org-entry-delete nil property)

[-- Attachment #5: Type: text/plain, Size: 185 bytes --]


For me they feels the same but I think the "always prompt" alternative
is better because it is simpler.

Simple is always good.

Sorry for spamming the change-log.

-- 
Mikael Fornius

[-- Attachment #6: 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] 10+ messages in thread

* Re: [PATCH] org-set/delete-property
  2010-03-11 16:43           ` [PATCH] org-set/delete-property Mikael Fornius
@ 2010-03-12 16:38             ` Carsten Dominik
  2010-03-12 17:13               ` Mikael Fornius
  0 siblings, 1 reply; 10+ messages in thread
From: Carsten Dominik @ 2010-03-12 16:38 UTC (permalink / raw)
  To: Mikael Fornius; +Cc: emacs-orgmode

Hi MIchael,

are these changes relative to the current git version, or relative to  
the state before your initial change?

- Carsten

On Mar 11, 2010, at 5:43 PM, Mikael Fornius wrote:

>
> Hmm... I realize I should have thought some more about this before
> posting the original patch.
>
> I have second thoughts:
>
> I think the behavior to take property under cursor as the one intended
> to change when editing properties feels forcing and may be confusing.
>
> Therefore I suggest two alternatives:
>
> make it default alternative
>
> <initial-input.diff>
> or always prompt (like before)
>
> <always-prompt.diff>
> For me they feels the same but I think the "always prompt" alternative
> is better because it is simpler.
>
> Simple is always good.
>
> Sorry for spamming the change-log.
>
> -- 
> Mikael Fornius

- Carsten

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

* Re: [PATCH] org-set/delete-property
  2010-03-12 16:38             ` Carsten Dominik
@ 2010-03-12 17:13               ` Mikael Fornius
  2010-03-12 17:26                 ` Carsten Dominik
  0 siblings, 1 reply; 10+ messages in thread
From: Mikael Fornius @ 2010-03-12 17:13 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

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

Carsten Dominik <carsten.dominik@gmail.com> writes:

> are these changes relative to the current git version, or relative to
> the state before your initial change?

They are relative to the current git version, I make a new one.

This is the change I would like to have applied if you agree:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Always prompt for property name. --]
[-- Type: text/x-patch, Size: 1447 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 28febc1..417727e 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2010-03-12  Mikael Fornius  <mfo@abc.se>
+
+	* org.el (org-set-property, org-delete-property): Do not use
+	property at cursor but prompt always.
+
 2010-03-12  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-latex.el (org-export-latex-make-header): Fully process
diff --git a/lisp/org.el b/lisp/org.el
index a4932a2..72dfa9d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12986,8 +12986,7 @@ in the current file."
   (interactive
    (let* ((completion-ignore-case t)
 	  (keys (org-buffer-property-keys nil t t))
-	  (prop0 (or (when (org-at-property-p) (org-match-string-no-properties 2))
-		     (org-icompleting-read "Property: " (mapcar 'list keys))))
+	  (prop0 (org-icompleting-read "Property: " (mapcar 'list keys)))
 	  (prop (if (member prop0 keys)
 		    prop0
 		  (or (cdr (assoc (downcase prop0)
@@ -13014,9 +13013,7 @@ in the current file."
   "In the current entry, delete PROPERTY."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (or (when (org-at-property-p) (org-match-string-no-properties 2))
-		    (org-icompleting-read
-		     "Property: " (org-entry-properties nil 'standard)))))
+	  (prop (org-icompleting-read "Property: " (org-entry-properties nil 'standard))))
      (list prop)))
   (message "Property %s %s" property
 	   (if (org-entry-delete nil property)

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


Thanks!

-- 
Mikael Fornius

[-- Attachment #4: 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] 10+ messages in thread

* Re: [PATCH] org-set/delete-property
  2010-03-12 17:13               ` Mikael Fornius
@ 2010-03-12 17:26                 ` Carsten Dominik
  0 siblings, 0 replies; 10+ messages in thread
From: Carsten Dominik @ 2010-03-12 17:26 UTC (permalink / raw)
  To: Mikael Fornius; +Cc: emacs-orgmode

OK, done, thanks.

- Carsten

On Mar 12, 2010, at 6:13 PM, Mikael Fornius wrote:

> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> are these changes relative to the current git version, or relative to
>> the state before your initial change?
>
> They are relative to the current git version, I make a new one.
>
> This is the change I would like to have applied if you agree:
>
> diff --git a/lisp/ChangeLog b/lisp/ChangeLog
> index 28febc1..417727e 100755
> --- a/lisp/ChangeLog
> +++ b/lisp/ChangeLog
> @@ -1,3 +1,8 @@
> +2010-03-12  Mikael Fornius  <mfo@abc.se>
> +
> +	* org.el (org-set-property, org-delete-property): Do not use
> +	property at cursor but prompt always.
> +
> 2010-03-12  Carsten Dominik  <carsten.dominik@gmail.com>
>
> 	* org-latex.el (org-export-latex-make-header): Fully process
> diff --git a/lisp/org.el b/lisp/org.el
> index a4932a2..72dfa9d 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -12986,8 +12986,7 @@ in the current file."
>   (interactive
>    (let* ((completion-ignore-case t)
> 	  (keys (org-buffer-property-keys nil t t))
> -	  (prop0 (or (when (org-at-property-p) (org-match-string-no- 
> properties 2))
> -		     (org-icompleting-read "Property: " (mapcar 'list keys))))
> +	  (prop0 (org-icompleting-read "Property: " (mapcar 'list keys)))
> 	  (prop (if (member prop0 keys)
> 		    prop0
> 		  (or (cdr (assoc (downcase prop0)
> @@ -13014,9 +13013,7 @@ in the current file."
>   "In the current entry, delete PROPERTY."
>   (interactive
>    (let* ((completion-ignore-case t)
> -	  (prop (or (when (org-at-property-p) (org-match-string-no- 
> properties 2))
> -		    (org-icompleting-read
> -		     "Property: " (org-entry-properties nil 'standard)))))
> +	  (prop (org-icompleting-read "Property: " (org-entry-properties  
> nil 'standard))))
>      (list prop)))
>   (message "Property %s %s" property
> 	   (if (org-entry-delete nil property)
>
> Thanks!
>
> -- 
> Mikael Fornius

- Carsten

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

end of thread, other threads:[~2010-03-12 17:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-11 12:49 [PATCH] org-at-property-p and related Mikael Fornius
2010-03-11 12:52 ` Mikael Fornius
2010-03-11 13:06   ` Mikael Fornius
2010-03-11 13:10     ` Carsten Dominik
2010-03-11 14:01       ` Mikael Fornius
2010-03-11 14:05         ` Carsten Dominik
2010-03-11 16:43           ` [PATCH] org-set/delete-property Mikael Fornius
2010-03-12 16:38             ` Carsten Dominik
2010-03-12 17:13               ` Mikael Fornius
2010-03-12 17:26                 ` Carsten Dominik

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