emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Mikael Fornius <mfo@abc.se>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-at-property-p and related
Date: Thu, 11 Mar 2010 13:49:34 +0100	[thread overview]
Message-ID: <878w9zkopt.fsf@eee.lan> (raw)

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

             reply	other threads:[~2010-03-11 12:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-11 12:49 Mikael Fornius [this message]
2010-03-11 12:52 ` [PATCH] org-at-property-p and related 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878w9zkopt.fsf@eee.lan \
    --to=mfo@abc.se \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).