[Orgmode] Re: [PATCH] org-at-property-p and related

2010-03-11 Thread Carsten Dominik

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





___
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


[Orgmode] Re: [PATCH] org-at-property-p and related

2010-03-11 Thread Mikael Fornius

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
___
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


Re: [Orgmode] Re: [PATCH] org-at-property-p and related

2010-03-11 Thread Carsten Dominik

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:


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





___
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


[Orgmode] Re: [PATCH] org-at-property-p and related

2010-03-11 Thread Mikael Fornius

Oh man! That was old.

Sorry. Third attempt:

This is the one:

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  
+
+	* 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  
 
 	* 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]*\\)\\]")

-- 
Mikael Fornius
___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://li

[Orgmode] Re: [PATCH] org-at-property-p and related

2010-03-11 Thread Mikael Fornius

Sorry the attached patch is inverted! :-)

Try this.

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  
+
+	* 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  
+
+	* 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  
 
 	* 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]*\\)\\]")

-- 
Mikael Fornius
___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Ema