emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Do not indent option keywords
@ 2013-05-09 19:14 Achim Gratz
  2013-05-09 20:34 ` Achim Gratz
  0 siblings, 1 reply; 6+ messages in thread
From: Achim Gratz @ 2013-05-09 19:14 UTC (permalink / raw)
  To: emacs-orgmode

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-org.el-do-not-indent-option-keyword-lines.patch --]
[-- Type: text/x-patch, Size: 853 bytes --]

From 1ed4564cd14369758167758bb8a2eb5c4d0d8f0e Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Thu, 9 May 2013 19:28:37 +0200
Subject: [PATCH] org.el: do not indent option keyword lines

* lisp/org.el (org-indent-line): Keep option keyword lines at column
  zero so they don't lose their decoration.
---
 lisp/org.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index bbb30d6..2d2e79f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -21975,6 +21975,8 @@ (defun org-indent-line ()
 			  (org-get-indentation (match-string 0))))
 		    (t
 		     (org-get-indentation (match-string 0))))))
+       ;; Option keywords
+       ((looking-at "^#\\+") (setq column 0))
        ;; This line has nothing special, look at the previous relevant
        ;; line to compute indentation
        (t
-- 
1.8.2.1


[-- Attachment #2: Type: text/plain, Size: 197 bytes --]



Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for KORG EX-800 and Poly-800MkII V0.9:
http://Synth.Stromeko.net/Downloads.html#KorgSDada

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

* Re: [PATCH] Do not indent option keywords
  2013-05-09 19:14 [PATCH] Do not indent option keywords Achim Gratz
@ 2013-05-09 20:34 ` Achim Gratz
  2013-05-10  6:26   ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Achim Gratz @ 2013-05-09 20:34 UTC (permalink / raw)
  To: emacs-orgmode

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

That was not the patch I was trying to send, sorry.  Second try:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org.el-do-not-indent-option-keyword-lines.patch --]
[-- Type: text/x-patch, Size: 1385 bytes --]

From 990257c497aa9fb0b8250d770c8e899762cc7abc Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Thu, 9 May 2013 22:30:08 +0200
Subject: [PATCH] org.el: do not indent option keyword lines

* lisp/org.el (org-indent-line): Keep option keyword lines at column
  zero so they don't lose their decoration.
---
 lisp/org.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 08570c3..b357c90 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -21932,6 +21932,11 @@ (defun org-indent-line ()
 			     (org-inlinetask-in-task-p)))
 	 (inline-re (and inline-task-p
 			 (org-inlinetask-outline-regexp)))
+	 (opt-re (org-make-options-regexp
+		  '("CATEGORY" "TODO" "COLUMNS" "STARTUP" "ARCHIVE"
+		    "LINK" "PRIORITIES" "CONSTANTS" "PROPERTY" "DRAWERS"
+		    "SETUPFILE" "OPTIONS")
+		  "\\(?:[a-zA-Z][0-9a-zA-Z_]*_TODO\\)"))
 	 column)
     (if (and orgstruct-is-++ (eq pos (point)))
 	(let ((indent-line-function (cadadr (assoc 'indent-line-function org-fb-vars))))
@@ -21976,6 +21981,8 @@ (defun org-indent-line ()
 			  (org-get-indentation (match-string 0))))
 		    (t
 		     (org-get-indentation (match-string 0))))))
+       ;; Option keywords
+       ((looking-at opt-re) (setq column 0))
        ;; This line has nothing special, look at the previous relevant
        ;; line to compute indentation
        (t
-- 
1.8.2.1


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



Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Samples for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra

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

* Re: [PATCH] Do not indent option keywords
  2013-05-09 20:34 ` Achim Gratz
@ 2013-05-10  6:26   ` Carsten Dominik
  2013-05-10  6:39     ` Achim Gratz
  0 siblings, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2013-05-10  6:26 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode

Hi Achim,

by decoration you mean font-lock support?

Maybe this would be a better fix:

	Modified lisp/org.el
diff --git a/lisp/org.el b/lisp/org.el
index 745fb82..43df094 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5867,7 +5867,8 @@ by a #."
 	   ((or (equal dc1 "+results")
 		(member dc1 '("+begin:" "+end:" "+caption:" "+label:"
 			      "+orgtbl:" "+tblfm:" "+tblname:" "+results:"
-			      "+call:" "+header:" "+headers:" "+name:"))
+			      "+call:" "+header:" "+headers:" "+name:"
+			      "+options:"))
 		(and (match-end 4) (equal dc3 "+attr")))
 	    (add-text-properties
 	     beg (match-end 0)

- Carsten

On 9.5.2013, at 22:34, Achim Gratz <Stromeko@nexgo.de> wrote:

> That was not the patch I was trying to send, sorry.  Second try:
> 
> From 990257c497aa9fb0b8250d770c8e899762cc7abc Mon Sep 17 00:00:00 2001
> From: Achim Gratz <Stromeko@Stromeko.DE>
> Date: Thu, 9 May 2013 22:30:08 +0200
> Subject: [PATCH] org.el: do not indent option keyword lines
> 
> * lisp/org.el (org-indent-line): Keep option keyword lines at column
>  zero so they don't lose their decoration.
> ---
> lisp/org.el | 7 +++++++
> 1 file changed, 7 insertions(+)
> 
> diff --git a/lisp/org.el b/lisp/org.el
> index 08570c3..b357c90 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -21932,6 +21932,11 @@ (defun org-indent-line ()
> 			     (org-inlinetask-in-task-p)))
> 	 (inline-re (and inline-task-p
> 			 (org-inlinetask-outline-regexp)))
> +	 (opt-re (org-make-options-regexp
> +		  '("CATEGORY" "TODO" "COLUMNS" "STARTUP" "ARCHIVE"
> +		    "LINK" "PRIORITIES" "CONSTANTS" "PROPERTY" "DRAWERS"
> +		    "SETUPFILE" "OPTIONS")
> +		  "\\(?:[a-zA-Z][0-9a-zA-Z_]*_TODO\\)"))
> 	 column)
>     (if (and orgstruct-is-++ (eq pos (point)))
> 	(let ((indent-line-function (cadadr (assoc 'indent-line-function org-fb-vars))))
> @@ -21976,6 +21981,8 @@ (defun org-indent-line ()
> 			  (org-get-indentation (match-string 0))))
> 		    (t
> 		     (org-get-indentation (match-string 0))))))
> +       ;; Option keywords
> +       ((looking-at opt-re) (setq column 0))
>        ;; This line has nothing special, look at the previous relevant
>        ;; line to compute indentation
>        (t
> -- 
> 1.8.2.1
> 
> 
> 
> Regards,
> Achim.
> -- 
> +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
> 
> Samples for the Waldorf Blofeld:
> http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra

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

* Re: [PATCH] Do not indent option keywords
  2013-05-10  6:26   ` Carsten Dominik
@ 2013-05-10  6:39     ` Achim Gratz
  2013-05-10 17:57       ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Achim Gratz @ 2013-05-10  6:39 UTC (permalink / raw)
  To: emacs-orgmode

Carsten Dominik writes:
> by decoration you mean font-lock support?

Yes, but I also don't think these should ever become indented in the
first place.  That's debatable of course, the syntax as defined by
org-element does not require this IIRC.

> Maybe this would be a better fix:
>
> 	Modified lisp/org.el
> diff --git a/lisp/org.el b/lisp/org.el
> index 745fb82..43df094 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -5867,7 +5867,8 @@ by a #."
>  	   ((or (equal dc1 "+results")
>  		(member dc1 '("+begin:" "+end:" "+caption:" "+label:"
>  			      "+orgtbl:" "+tblfm:" "+tblname:" "+results:"
> -			      "+call:" "+header:" "+headers:" "+name:"))
> +			      "+call:" "+header:" "+headers:" "+name:"
> +			      "+options:"))
>  		(and (match-end 4) (equal dc3 "+attr")))
>  	    (add-text-properties
>  	     beg (match-end 0)

Sure, that helps too and has certainly less potential for controversy.

I think we should make an effort to shift most if not all the regex
stuff in org.el into org-element.  There's far too much duplication with
subtle differences sprinkled all over the place to get match data to
work with and it's almost hopeless to try and find all such uses for a
single element.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf rackAttack:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

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

* Re: [PATCH] Do not indent option keywords
  2013-05-10  6:39     ` Achim Gratz
@ 2013-05-10 17:57       ` Carsten Dominik
  2013-05-10 18:30         ` Achim Gratz
  0 siblings, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2013-05-10 17:57 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode


On 10.5.2013, at 08:39, Achim Gratz <Stromeko@nexgo.de> wrote:

> Carsten Dominik writes:
>> by decoration you mean font-lock support?
> 
> Yes, but I also don't think these should ever become indented in the
> first place.  That's debatable of course, the syntax as defined by
> org-element does not require this IIRC.

Well, which are the ones you think should never become indented?  OPTIONS, TITLE, of maybe you mean the whole suite of keywords?

I sometimes put the setup below a major headline "* setup" or so, to make them hide away and give the buffer a clean look.  Depending on indentation setting it then does make some sense to allow indentation.  So I think the font-lock fix is more important than the indentation one.

Please read on below.


> 
>> Maybe this would be a better fix:
>> 
>> 	Modified lisp/org.el
>> diff --git a/lisp/org.el b/lisp/org.el
>> index 745fb82..43df094 100644
>> --- a/lisp/org.el
>> +++ b/lisp/org.el
>> @@ -5867,7 +5867,8 @@ by a #."
>> 	   ((or (equal dc1 "+results")
>> 		(member dc1 '("+begin:" "+end:" "+caption:" "+label:"
>> 			      "+orgtbl:" "+tblfm:" "+tblname:" "+results:"
>> -			      "+call:" "+header:" "+headers:" "+name:"))
>> +			      "+call:" "+header:" "+headers:" "+name:"
>> +			      "+options:"))
>> 		(and (match-end 4) (equal dc3 "+attr")))
>> 	    (add-text-properties
>> 	     beg (match-end 0)
> 
> Sure, that helps too and has certainly less potential for controversy.
> 
> I think we should make an effort to shift most if not all the regex
> stuff in org.el into org-element.  There's far too much duplication with
> subtle differences sprinkled all over the place to get match data to
> work with and it's almost hopeless to try and find all such uses for a
> single element.

What do you mean?  Do you meant to use the org-elemnt parser
and base also font-lock on it?  Or do you mean all the definitions
of regexp constants.  This sounds desirable - but it also sounds
like an extremely daunting task with possibilities for problems
in side effects of regexp matching that will be difficult to find
and might only show after a long time.  I guess we could start
such a process one regexp at a time.

- Carsten

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

* Re: [PATCH] Do not indent option keywords
  2013-05-10 17:57       ` Carsten Dominik
@ 2013-05-10 18:30         ` Achim Gratz
  0 siblings, 0 replies; 6+ messages in thread
From: Achim Gratz @ 2013-05-10 18:30 UTC (permalink / raw)
  To: emacs-orgmode

Carsten Dominik writes:
> Well, which are the ones you think should never become indented?
> OPTIONS, TITLE, of maybe you mean the whole suite of keywords?

OPTIONS, TITLE, PROPERTY for sure.  But as I said, someone else may
actually want them to indent, so making sure they don't drop their
font-lock-properties when indented is a better idea.

>> I think we should make an effort to shift most if not all the regex
>> stuff in org.el into org-element.  There's far too much duplication with
>> subtle differences sprinkled all over the place to get match data to
>> work with and it's almost hopeless to try and find all such uses for a
>> single element.
>
> What do you mean?  Do you meant to use the org-elemnt parser
> and base also font-lock on it?

Yes, but I'm not sure it is fully up to the task yet.  But it ought to
be, since there is no point in defining the syntax of the same piece of
Org in more than one place.

> Or do you mean all the definitions of regexp constants.

That too.  Although as you note, this is fraught with peril.  But if
we'd see it through, then the result would be a lot less troublesome to
maintain.  Look at all the places in org.el where a match for headline
tags is constructed for instance…

> This sounds desirable - but it also sounds like an extremely daunting
> task with possibilities for problems in side effects of regexp
> matching that will be difficult to find and might only show after a
> long time.  I guess we could start such a process one regexp at a
> time.

Please see

http://thread.gmane.org/gmane.emacs.orgmode/69065/focus=71563

for a patch that attempts to implement some of this for node properties.
It doesn't yet do away with the regex in org.el since there's no obvious
convention for org-element to produce match data that can be used by the
caller -- but if there was, then the regex could move into org-element
I'd think.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf rackAttack:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

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

end of thread, other threads:[~2013-05-10 18:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-09 19:14 [PATCH] Do not indent option keywords Achim Gratz
2013-05-09 20:34 ` Achim Gratz
2013-05-10  6:26   ` Carsten Dominik
2013-05-10  6:39     ` Achim Gratz
2013-05-10 17:57       ` Carsten Dominik
2013-05-10 18:30         ` Achim Gratz

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