From: Achim Gratz <Stromeko@nexgo.de>
To: emacs-orgmode@gnu.org
Subject: Re: :session question
Date: Thu, 09 May 2013 20:52:40 +0200 [thread overview]
Message-ID: <87k3n8gf47.fsf@Rainer.invalid> (raw)
In-Reply-To: 87sj264o0f.fsf@gmail.com
[-- Attachment #1: Type: text/plain, Size: 901 bytes --]
Eric Schulte writes:
> I think these are great ideas. Personally I'd love to see them
> implemented. Unfortunately I don't have time to work on an
> implementation currently. I'm surprised that none of the users who
> motivated this discussion have chimed in. Their opinions may be more
> valuable than my own in this regard (as I'm not a heavy #+Property
> user).
The change on the Babel side was just a few lines, but reconciling Org's
notion of property syntax in various places proved to be more difficult.
It's still not very well tested (it does survive the test suite
obviously) and I'll need to write tests and documentation (help is
welcome). Also, a new-style form of specifying header arguments for all
languages (to then deprecate the old form) is missing at the moment
since I'd like to get feedback on the language specific side first.
With these caveats, here's the patchset:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org.el-improve-org-property-re-and-use-it-throughout.patch --]
[-- Type: text/x-patch, Size: 5278 bytes --]
From fe5f9f46896939179f0163c2ce10f8738ebde709 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Thu, 9 May 2013 19:47:59 +0200
Subject: [PATCH 1/2] org.el: improve org-property-re and use it throughout
* lisp/org.el (org-property-re): Improve definition so that this regex
can be used in all situations. Extend docstring with explanation of
matching groups.
(org-at-property-p): Implement using `org-element-at-point'.
(org-entry-properties, org-buffer-property-keys, org-indent-line):
Use `org-property-re' and adjust match group numbers accordingly.
* lisp/org-element.el (org-element-node-property-parser): Use
`org-property-re' and adjust match group numbers accordingly. Move
`looking-at' out of the let clause to not rely on the unspecified
evaluation order inside the let.
---
lisp/org-element.el | 6 +++---
lisp/org.el | 40 ++++++++++++++++++++--------------------
2 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index aafba88..f180f91 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1973,11 +1973,11 @@ (defun org-element-node-property-parser (limit)
containing `:key', `:value', `:begin', `:end' and `:post-blank'
keywords."
(save-excursion
+ (looking-at org-property-re)
(let ((case-fold-search t)
(begin (point))
- (key (progn (looking-at "[ \t]*:\\(.*?\\):[ \t]+\\(.*?\\)[ \t]*$")
- (org-match-string-no-properties 1)))
- (value (org-match-string-no-properties 2))
+ (key (org-match-string-no-properties 2))
+ (value (org-match-string-no-properties 3))
(pos-before-blank (progn (forward-line) (point)))
(end (progn (skip-chars-forward " \r\t\n" limit)
(if (eobp) (point) (point-at-bol)))))
diff --git a/lisp/org.el b/lisp/org.el
index 1e28d93..b2e3836 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6139,8 +6139,15 @@ (defun org-outline-level ()
(defvar org-font-lock-keywords nil)
-(defconst org-property-re (org-re "^[ \t]*\\(:\\([-[:alnum:]_]+\\+?\\):\\)[ \t]*\\([^ \t\r\n].*\\)")
- "Regular expression matching a property line.")
+(defconst org-property-re
+ "^\\(?4:[ \t]*\\)\\(?1::\\(?2:.*?\\):\\)[ \t]+\\(?3:[^ \t\r\n].*?\\)\\(?5:[ \t]*\\)$"
+ "Regular expression matching a property line.
+There are four matching groups:
+1: :PROPKEY: including the leading and trailing colon,
+2: PROPKEY without the leading and trailing colon,
+3: PROPVAL without leading or trailing spaces,
+4: the indentation of the current line,
+5: trailing whitespace.")
(defvar org-font-lock-hook nil
"Functions to be called for special font lock stuff.")
@@ -15116,13 +15123,9 @@ (defun org-set-effort (&optional value increment)
(defun org-at-property-p ()
"Is cursor inside a property drawer?"
(save-excursion
- (beginning-of-line 1)
- (when (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))
- (save-match-data ;; Used by calling procedures
- (let ((p (point))
- (range (unless (org-before-first-heading-p)
- (org-get-property-block))))
- (and range (<= (car range) p) (< p (cdr range))))))))
+ (when (equal 'node-property (car (org-element-at-point)))
+ (beginning-of-line 1)
+ (looking-at org-property-re))))
(defun org-get-property-block (&optional beg end force)
"Return the (beg . end) range of the body of the property drawer.
@@ -15247,11 +15250,10 @@ (defun org-entry-properties (&optional pom which specific)
(setq range (org-get-property-block beg end))
(when range
(goto-char (car range))
- (while (re-search-forward
- (org-re "^[ \t]*:\\([[:alpha:]][[:alnum:]_-]*\\):[ \t]*\\(\\S-.*\\)?")
+ (while (re-search-forward org-property-re
(cdr range) t)
- (setq key (org-match-string-no-properties 1)
- value (org-trim (or (org-match-string-no-properties 2) "")))
+ (setq key (org-match-string-no-properties 2)
+ value (org-trim (or (org-match-string-no-properties 3) "")))
(unless (member key excluded)
(push (cons key (or value "")) props)))))
(if clocksum
@@ -15520,10 +15522,9 @@ (defun org-buffer-property-keys (&optional include-specials include-defaults inc
(while (re-search-forward org-property-start-re nil t)
(setq range (org-get-property-block))
(goto-char (car range))
- (while (re-search-forward
- (org-re "^[ \t]*:\\([-[:alnum:]_]+\\):")
+ (while (re-search-forward org-property-re
(cdr range) t)
- (add-to-list 'rtn (org-match-string-no-properties 1)))
+ (add-to-list 'rtn (org-match-string-no-properties 2)))
(outline-next-heading))))
(when include-specials
@@ -22029,11 +22030,10 @@ (defun org-indent-line ()
;; Special polishing for properties, see `org-property-format'
(setq column (current-column))
(beginning-of-line 1)
- (if (looking-at
- "\\([ \t]*\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)")
- (replace-match (concat (match-string 1)
+ (if (looking-at org-property-re)
+ (replace-match (concat (match-string 4)
(format org-property-format
- (match-string 2) (match-string 3)))
+ (match-string 1) (match-string 3)))
t t))
(org-move-to-column column))))
--
1.8.2.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-ob-core-allow-language-specific-header-arguments-in-.patch --]
[-- Type: text/x-patch, Size: 2916 bytes --]
From 659663d7f053f85872e572aca83541b470070abf Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Thu, 9 May 2013 20:01:45 +0200
Subject: [PATCH 2/2] ob-core: allow language specific header arguments in
properties
* lisp/ob-core.el (org-babel-insert-header-arg,
org-babel-parse-src-block-match): Replace `if' with empty else part
by `when' for readability.
(org-babel-parse-src-block-match,
org-babel-parse-inline-src-block-match): Inquire for language
specific header args from properties and integrate them after other
default header args.
This allows for header arguments to be specified as
properties (including inheritance).
#+PROPERTY: header-args:R :session "*R-property*"
:PROPERTIES:
:header-args:R: :session "*R-drawer*"
:END:
---
lisp/ob-core.el | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 06d2520..c719089 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -757,7 +757,7 @@ (defun org-babel-insert-header-arg ()
(lang-headers (intern (concat "org-babel-header-args:" lang)))
(headers (org-babel-combine-header-arg-lists
org-babel-common-header-args-w-values
- (if (boundp lang-headers) (eval lang-headers) nil)))
+ (when (boundp lang-headers) (eval lang-headers))))
(arg (org-icompleting-read
"Header Arg: "
(mapcar
@@ -1309,6 +1309,9 @@ (defun org-babel-parse-src-block-match ()
(let* ((block-indentation (length (match-string 1)))
(lang (org-no-properties (match-string 2)))
(lang-headers (intern (concat "org-babel-default-header-args:" lang)))
+ (lang-props (save-match-data
+ (org-entry-get (point) (concat "header-args:" lang)
+ 'inherit 'literal-nil)))
(switches (match-string 3))
(body (org-no-properties
(let* ((body (match-string 5))
@@ -1329,8 +1332,9 @@ (defun org-babel-parse-src-block-match ()
(buffer-string)))
(org-babel-merge-params
org-babel-default-header-args
- (if (boundp lang-headers) (eval lang-headers) nil)
+ (when (boundp lang-headers) (eval lang-headers))
(org-babel-params-from-properties lang)
+ (org-babel-parse-header-arguments lang-props)
(org-babel-parse-header-arguments
(org-no-properties (or (match-string 4) ""))))
switches
@@ -1339,6 +1343,9 @@ (defun org-babel-parse-src-block-match ()
(defun org-babel-parse-inline-src-block-match ()
"Parse the results from a match of the `org-babel-inline-src-block-regexp'."
(let* ((lang (org-no-properties (match-string 2)))
+ (lang-props (save-match-data
+ (org-entry-get (point) (concat "header-args:" lang)
+ 'inherit 'literal-nil)))
(lang-headers (intern (concat "org-babel-default-header-args:" lang))))
(list lang
(org-unescape-code-in-string (org-no-properties (match-string 5)))
--
1.8.2.1
[-- Attachment #4: Type: text/plain, Size: 187 bytes --]
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Wavetables for the Terratec KOMPLEXER:
http://Synth.Stromeko.net/Downloads.html#KomplexerWaves
next prev parent reply other threads:[~2013-05-09 18:53 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-25 9:37 :session question Andreas Röhler
2013-03-25 23:58 ` Michael Gauland
2013-03-26 0:46 ` Eric Schulte
2013-03-26 8:37 ` Andreas Röhler
2013-03-26 9:12 ` Rainer M Krug
2013-03-26 9:23 ` Andreas Leha
2013-03-26 12:37 ` Eric Schulte
2013-03-26 12:44 ` Andreas Leha
2013-03-26 12:55 ` Achim Gratz
2013-03-26 15:31 ` Eric Schulte
2013-03-27 8:01 ` :session question - header argument setting Rainer M Krug
2013-03-27 8:35 ` Sebastien Vauban
2013-03-27 8:52 ` :session question Andreas Röhler
2013-03-27 9:27 ` Andreas Leha
2013-03-27 11:37 ` Andreas Röhler
2013-03-27 11:48 ` Nick Dokos
2013-03-27 12:18 ` Andreas Röhler
2013-03-27 12:22 ` Rainer M Krug
2013-03-27 12:47 ` Andreas Röhler
2013-03-27 12:43 ` Eric Schulte
2013-03-27 13:26 ` Andreas Röhler
2013-03-27 13:29 ` Andreas Leha
2013-03-27 15:47 ` Eric Schulte
2013-03-27 20:20 ` Andreas Leha
2013-03-27 20:35 ` Eric Schulte
2013-03-28 10:25 ` Andreas Leha
2013-03-28 13:06 ` John Hendy
2013-03-28 19:35 ` :session question - a simple PATCH Andreas Leha
2013-03-29 9:59 ` Achim Gratz
2013-03-29 14:38 ` Eric Schulte
2013-03-28 13:22 ` :session question John Hendy
2013-03-27 20:59 ` Andreas Röhler
2013-03-27 11:19 ` Andreas Leha
2013-04-28 15:46 ` Achim Gratz
2013-05-01 17:18 ` Eric Schulte
2013-05-01 17:36 ` Achim Gratz
2013-05-09 18:52 ` Achim Gratz [this message]
2013-06-07 16:15 ` Achim Gratz
2013-06-07 19:07 ` :session question -- and changes to #+Property: syntax Eric Schulte
2013-06-07 19:49 ` Achim Gratz
2013-06-07 20:22 ` Andreas Leha
2013-06-10 8:16 ` Rainer M Krug
2013-06-08 7:47 ` Achim Gratz
2013-06-08 18:08 ` Eric Schulte
2013-06-08 20:48 ` Achim Gratz
2013-06-10 8:21 ` Rainer M Krug
2013-06-10 19:16 ` Achim Gratz
2013-06-18 20:41 ` Achim Gratz
2013-06-19 10:10 ` Michael Brand
2013-06-20 16:27 ` Eric Schulte
2013-06-20 17:47 ` Achim Gratz
2013-06-20 18:31 ` Eric Schulte
2013-06-20 19:14 ` Achim Gratz
2013-06-20 19:28 ` Eric Schulte
2013-06-23 17:50 ` Achim Gratz
2013-06-25 14:20 ` Eric Schulte
2013-06-25 18:28 ` Achim Gratz
2013-06-10 8:14 ` :session question Rainer M Krug
2013-06-10 8:12 ` Rainer M Krug
2013-03-27 8:26 ` Andreas Röhler
2013-03-26 6:41 ` Andreas Röhler
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=87k3n8gf47.fsf@Rainer.invalid \
--to=stromeko@nexgo.de \
--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).