Re: [O] orgstruct-mode with custom headline prefix

2013-02-26 Thread Stephen Eglen

> Yes, you can send attachments to the list -- in general, please share
> bugs publicly as much as possible, receiving private emails about bugs
> is not encouraging for the maintainer (in this case Christopher) and
> not useful for the other people on this list, as they cannot contribute
> to debugging.
>
> So, feel free to share attachments :)

Thanks Bastien; as you'll see, in the meantime Christopher already fixed
this issue in master.  Next time, I'll keep it on the list!

Stephen




Re: [O] orgstruct-mode with custom headline prefix

2013-02-26 Thread Christopher Schmidt
Stephen Eglen  writes:
> Thanks Bastien for the explanation.  I can now get support for
> orgstruct without setting outline-regexp, but in so doing I found an
> odd error.  I've sent Christopher a minimal example, but didn't send
> it to the list as I wasn't sure about whether attachments could be
> sent to the list?

This is fixed in master.

ff92e68 org.el: Rebind structure-related variables within 
org-run-like-in-org-mode

Christopher



Re: [O] orgstruct-mode with custom headline prefix

2013-02-26 Thread Bastien
Stephen Eglen  writes:

> Thanks Bastien for the explanation.  I can now get support for orgstruct
> without setting outline-regexp, but in so doing I found an odd error.
> I've sent Christopher a minimal example, but didn't send it to the list
> as I wasn't sure about whether attachments could be sent to the
> list?

Yes, you can send attachments to the list -- in general, please share
bugs publicly as much as possible, receiving private emails about bugs
is not encouraging for the maintainer (in this case Christopher) and
not useful for the other people on this list, as they cannot contribute
to debugging.

So, feel free to share attachments :)

-- 
 Bastien



Re: [O] orgstruct-mode with custom headline prefix

2013-02-26 Thread Stephen Eglen
>
> No, it is not.

Thanks Bastien for the explanation.  I can now get support for orgstruct
without setting outline-regexp, but in so doing I found an odd error.
I've sent Christopher a minimal example, but didn't send it to the list
as I wasn't sure about whether attachments could be sent to the list?

Stephen




Re: [O] orgstruct-mode with custom headline prefix

2013-02-22 Thread Bastien
Hi Stephen,

Dr Stephen J Eglen  writes:

> I just wanted to check though whether we need to set outline-regexp; 

No, it is not.

> I think this part of `org-cycle' requires outline-regexp to be set,
> but I just wanted to check whether this was a pre-requisite, as it
> then seems that we are setting two similar regexps.

The outline-regexp is useful in outline-mode.

In org-mode, which is derived from outline-mode, you don't want to
change outline-regexp directly, but org-outline-regexp instead.

orgstruct-mode is different: it relies both on the value of
`orgstruct-heading-prefix-regexp' (which you need to set) and on
the value of `org-outline-regexp' (which you don't need to set).

HTH,

-- 
 Bastien



Re: [O] orgstruct-mode with custom headline prefix

2013-02-19 Thread Dr Stephen J Eglen
Christopher Schmidt  ch.ristopher.com> writes:

> 
> Christopher Schmidt  ch.ristopher.com> writes:
> > I will push a fix ASAP.
> 
> I did that now.
> 
> d6f69f5 org.el: Use let instead of progv in org-run-like-in-org-mode
> ea2d107 org.el: Declare orgstruct-mode
> 
> Christopher
> 
> 


hi Christopher, 

I'm trying to add support for orgstruct-mode to R buffers (via ESS).
I think I'm nearly there, with the following magic at the end of my
buffers:


### Local Variables:
### eval: (orgstruct-mode 1)
### outline-regexp: "### "
### orgstruct-heading-prefix-regexp: "### "
### End:

so that lines such as:

### * section heading

become section headings.  This is really neat, thanks for your work.

I just wanted to check though whether we need to set outline-regexp; I
think this part of `org-cycle' requires outline-regexp to be set, but
I just wanted to check whether this was a pre-requisite, as it then
seems that we are setting two similar regexps.  Not a big deal, but
just wanted to check.  Most major modes (emacs-lisp, python, perl)
that I checked already set outline-regexp, whereas we currently don't
set it in ESS.

(if (not (derived-mode-p 'org-mode))
outline-regexp

Thanks, Stephen





Re: [O] orgstruct-mode with custom headline prefix

2013-02-13 Thread Achim Gratz
Christopher Schmidt writes:
> I did that now.
>
> d6f69f5 org.el: Use let instead of progv in org-run-like-in-org-mode
> ea2d107 org.el: Declare orgstruct-mode

Thanks for fixing this.


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

SD adaptation for Waldorf microQ V2.22R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada




Re: [O] orgstruct-mode with custom headline prefix

2013-02-13 Thread Sebastien Vauban
Hi Christopher and Bastien,

Christopher Schmidt wrote:
> Christopher Schmidt  writes:
>> I will push a fix ASAP.
>
> I did that now.
>
> d6f69f5 org.el: Use let instead of progv in org-run-like-in-org-mode
> ea2d107 org.el: Declare orgstruct-mode

FYI, I still have the reported problem when composing an email:

Lisp nesting exceeds `max-lisp-eval-depth'

Org-mode version 7.9.3e (7.9.3e-1002-gd6f69f @ 
d:/Users/fni/Public/Repositories/org-mode/lisp/)

Best regards,
  Seb

-- 
Sebastien Vauban




Re: [O] orgstruct-mode with custom headline prefix

2013-02-13 Thread Christopher Schmidt
Christopher Schmidt  writes:
> I will push a fix ASAP.

I did that now.

d6f69f5 org.el: Use let instead of progv in org-run-like-in-org-mode
ea2d107 org.el: Declare orgstruct-mode

Christopher



Re: [O] orgstruct-mode with custom headline prefix

2013-02-12 Thread Bastien
Hi Christopher,

Christopher Schmidt  writes:

> These internal functions should have been autoloaded.  progv is pretty
> obscure and I guess noone has noticed that bug in cl-macs until now.

The attached patch gets rid of progv by using org-let.

As a side-effect, it fixes a but that was introduced with
your change: M-x turn-on-orgstruct RET in message-mode and
try to move around list items for example... it will choke
at org-auto-fill-function not being defined.  The bug is
not limited to this example of course.

Let me know if it breaks something I may have overlooked.

>> Emacs 24.3.93 seems to have that fixed,
>
> So does 24.2.x.
>
> I will push a fix ASAP.
>
>> but complains about this instead:
>> In org-heading-components:
>> org.el:7436:16:Warning: reference to free variable `orgstruct-mode'
>
> This one is bogus, the variable is defined later on.  I will silence
> that warning.

Thanks in advance for this!

diff --git a/lisp/org.el b/lisp/org.el
index 5892489..b251cbe 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8781,7 +8781,7 @@ Possible values in the list of contexts are `table', `headline', and `item'."
  (setq x
(if (symbolp x)
(list x)
- (list (car x) (cdr x
+ (list (car x) (list 'quote (cdr x)
  (if (and (not (get (car x) 'org-state))
   (string-match
"^\\(org-\\|orgtbl-\\|outline-\\|comment-\\|paragraph-\\|auto-fill\\|normal-auto-fill\\|fill-paragraph\\|indent-\\)"
@@ -8810,15 +8810,8 @@ call CMD."
   (org-load-modules-maybe)
   (unless org-local-vars
 (setq org-local-vars (org-get-local-variables)))
-  (let (symbols values)
-(dolist (var org-local-vars)
-  (when (or (not (boundp (car var)))
-		(eq (symbol-value (car var))
-		(default-value (car var
-(push (car var) symbols)
-(push (cadr var) values)))
-(progv symbols values
-  (call-interactively cmd
+  (org-let org-local-vars
+(call-interactively cmd)))
 
  Archiving
 

-- 
 Bastien


Re: [O] orgstruct-mode with custom headline prefix

2013-02-12 Thread Christopher Schmidt
Achim Gratz  writes:
> This introduces the following failures in compilation with Emacs 24.2
> and has a high chance of not working at all in some setups:
> --8<---cut here---start->8---
> Compiling /home/gratz/lisp/org-mode/lisp/org.el...
>
> In org-heading-components:
> org.el:7436:16:Warning: reference to free variable `orgstruct-mode'
>
> In org-run-like-in-org-mode:
> org.el:8841:20:Warning: function `cl-progv-before' from cl package called at
> runtime
>
> In end of data:
> org.el:23217:1:Warning: the function `cl-progv-after' is not known to be
> defined.
> --8<---cut here---end--->8---

Great.

> …and no, I have no idea how that single progv macro manages to expand to
> use these two functions.

These internal functions should have been autoloaded.  progv is pretty
obscure and I guess noone has noticed that bug in cl-macs until now.

> Emacs 24.3.93 seems to have that fixed,

So does 24.2.x.

I will push a fix ASAP.

> but complains about this instead:
> In org-heading-components:
> org.el:7436:16:Warning: reference to free variable `orgstruct-mode'

This one is bogus, the variable is defined later on.  I will silence
that warning.

Christopher



Re: [O] orgstruct-mode with custom headline prefix

2013-02-12 Thread Achim Gratz
Christopher Schmidt writes:
> This is in master now.  The commit is a3f6570.

This introduces the following failures in compilation with Emacs 24.2
and has a high chance of not working at all in some setups:

--8<---cut here---start->8---
Compiling /home/gratz/lisp/org-mode/lisp/org.el...

In org-heading-components:
org.el:7436:16:Warning: reference to free variable `orgstruct-mode'

In org-run-like-in-org-mode:
org.el:8841:20:Warning: function `cl-progv-before' from cl package called at
runtime

In end of data:
org.el:23217:1:Warning: the function `cl-progv-after' is not known to be
defined.
--8<---cut here---end--->8---

…and no, I have no idea how that single progv macro manages to expand to
use these two functions.

Emacs 24.3.93 seems to have that fixed, but complains about this
instead:


In org-heading-components:
org.el:7436:16:Warning: reference to free variable `orgstruct-mode'

In end of data:
org.el:23217:1:Warning: the following functions might not be defined at
runtime: easy-menu-add, format-spec



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




Re: [O] orgstruct-mode with custom headline prefix

2013-02-11 Thread Bastien
Christopher Schmidt  writes:

> Christopher Schmidt  writes:
>> Here is the patch.  Now one just needs
>>
>> ;; Local Variables:
>> ;; eval: (orgstruct-mode 1)
>> ;; orgstruct-heading-prefix-regexp: ";;; "
>> ;; End:
>
> This is in master now.  The commit is a3f6570.

Thanks a lot!

-- 
 Bastien



Re: [O] orgstruct-mode with custom headline prefix

2013-02-10 Thread Christopher Schmidt
Christopher Schmidt  writes:
> Here is the patch.  Now one just needs
>
> ;; Local Variables:
> ;; eval: (orgstruct-mode 1)
> ;; orgstruct-heading-prefix-regexp: ";;; "
> ;; End:

This is in master now.  The commit is a3f6570.

Christopher



Re: [O] orgstruct-mode with custom headline prefix

2013-02-01 Thread Carsten Dominik
Hi Christopher,

I have trouble applying it, can you please send the patch as an attachments 
instead of inline, and make sure it is agains the current master?  Thanks.

- Carsten

On 31 jan. 2013, at 21:06, Christopher Schmidt  
wrote:

> Bastien  writes:
>> PS: To make things clear: I'm confident the patch is good, but I will
>> put it higher on my patch review process if I know the agenda does not
>> slow down :)
> 
> Here is the patch.  Now one just needs
> 
>;; Local Variables:
>;; eval: (orgstruct-mode 1)
>;; orgstruct-heading-prefix-regexp: ";;; "
>;; End:
> 
> It cannot get any easier than this.
> 
>2013-01-31  Christopher Schmidt  
> 
>* org.el (org-cycle-global-status, org-cycle-subtree-status): Set
>state property.
>(org-heading-components): Use org-heading-regexp in
>orgstruct-mode.
>(orgstruct-heading-prefix-regexp, orgstruct-setup-hook): New
>options.
>(orgstruct-initialized): New variable.
>(orgstruct-mode): Simplify implementation.
>(orgstruct-setup): Simplify implementation.  Translate keys to
>their most general equivalent.
>(orgstruct-make-binding): Generate index on the fly.  Discard
>alternative keys.  Bind variables according to
>orgstruct-heading-prefix-regexp.
>(org-get-local-variables): Honour state property.
>(org-run-like-in-org-mode): Do not override variables with
>non-default values.
>(org-forward-heading-same-level): Do not skip to headlines on
>another level.  Handle negative prefix argument correctly.
>(org-backward-heading-same-level): Use
>org-forward-heading-same-level.
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -6223,8 +6223,10 @@ and subscripts."
> 
> (defvar org-cycle-global-status nil)
> (make-variable-buffer-local 'org-cycle-global-status)
> +(put 'org-cycle-global-status 'org-state t)
> (defvar org-cycle-subtree-status nil)
> (make-variable-buffer-local 'org-cycle-subtree-status)
> +(put 'org-cycle-subtree-status 'org-state t)
> 
> (defvar org-inlinetask-min-level)
> 
> @@ -7403,13 +7405,24 @@ This is a list with the following elements:
> - the tags string, or nil."
>   (save-excursion
> (org-back-to-heading t)
> -(if (let (case-fold-search) (looking-at org-complex-heading-regexp))
> - (list (length (match-string 1))
> -   (org-reduced-level (length (match-string 1)))
> -   (org-match-string-no-properties 2)
> -   (and (match-end 3) (aref (match-string 3) 2))
> -   (org-match-string-no-properties 4)
> -   (org-match-string-no-properties 5)
> +(if (let (case-fold-search)
> +  (looking-at
> +   (if orgstruct-mode
> +   org-heading-regexp
> + org-complex-heading-regexp)))
> +(if orgstruct-mode
> +(list (length (match-string 1))
> +  (org-reduced-level (length (match-string 1)))
> +  nil
> +  nil
> +  (match-string 2)
> +  nil)
> +  (list (length (match-string 1))
> +(org-reduced-level (length (match-string 1)))
> +(org-match-string-no-properties 2)
> +(and (match-end 3) (aref (match-string 3) 2))
> +(org-match-string-no-properties 4)
> +(org-match-string-no-properties 5))
> 
> (defun org-get-entry ()
>   "Get the entry text, after heading, entire subtree."
> @@ -8482,12 +8495,19 @@ If WITH-CASE is non-nil, the sorting will be 
> case-sensitive."
> ;; command.  There might be problems if any of the keys is otherwise
> ;; used as a prefix key.
> 
> -;; Another challenge is that the key binding for TAB can be tab or \C-i,
> -;; likewise the binding for RET can be return or \C-m.  Orgtbl-mode
> -;; addresses this by checking explicitly for both bindings.
> +(defcustom orgstruct-heading-prefix-regexp ""
> +  "Regexp that matches the custom prefix of Org headlines in
> +orgstruct(++)-mode."
> +  :group 'org
> +  :type 'string)
> +;;;###autoload(put 'orgstruct-heading-prefix-regexp 'safe-local-variable 
> 'stringp)
> +
> +(defcustom orgstruct-setup-hook nil
> +  "Hook run after orgstruct-mode-map is filled."
> +  :group 'org
> +  :type 'hook)
> 
> -(defvar orgstruct-mode-map (make-sparse-keymap)
> -  "Keymap for the minor `orgstruct-mode'.")
> +(defvar orgstruct-initialized nil)
> 
> (defvar org-local-vars nil
>   "List of local variables, for use by `orgstruct-mode'.")
> @@ -8498,26 +8518,13 @@ If WITH-CASE is non-nil, the sorting will be 
> case-sensitive."
> This mode is for using Org-mode structure commands in other
> modes.  The following keys behave as if Org-mode were active, if
> the cursor is on a headline, or on a plain list item (both as
> -defined by Org-mode).
> -
> -M-upMove entry/item up
> -M-down   M

Re: [O] orgstruct-mode with custom headline prefix

2013-01-31 Thread Thorsten Jolitz
Christopher Schmidt  writes:

> Here is the patch.  Now one just needs
>
> ;; Local Variables:
> ;; eval: (orgstruct-mode 1)
> ;; orgstruct-heading-prefix-regexp: ";;; "
> ;; End:
>
> It cannot get any easier than this.

Just a question - why ";;; " and not ";; " (i.e. ";; \*+ ")? 

I (still) don't use orgstruct-mode instead of outline-minor-mode, but
can easily use full org-mode functionality in Emacs Lisp files by
marking & outcommenting/uncommenting regions that look like this

,---
| ;; * level1
| ;; ** level2
| ;; text text text text
| ;; ** level2
| ;; text text text text
| 
| (defun ...)
`---

,---
| * level1
| ** level2
| text text text text
| ** level2
| text text text text
| 
| (defun ...)
`---

and toggling major modes between Emacs Lisp and Org-mode. 

With prefixes like ';;; *' or ';;*' this becomes less convenient in my
eyes, since 'M-x comment-region' can't be applied anymore. 

-- 
cheers,
Thorsten




Re: [O] orgstruct-mode with custom headline prefix

2013-01-31 Thread Christopher Schmidt
Christopher Schmidt  writes:

This is the memory profiler result.

> a2febd210182d9e1a37b0d7fd9ee007a10abc4bc refs/remotes/origin/HEAD
> Saved working directory and index state WIP on master: a2febd2 Merge 
> branch 'maint'
> HEAD is now at a2febd2 Merge branch 'maint'
> OVERVIEW
> Setting `org-agenda-files' temporarily since "emacs -q" would overwrite 
> customizations
> File added to front of agenda file list
> CPU and memory profiler started
> 
> 12.207549810409546
>
>
> + normal-top-level 46,533,611  74%
> + command-line-16,385,759  10%
> + command-line  5,800,077   9%
> + eval  2,639,778   4%
> + progn   690,611   1%
> + let  70,947   0%
> + apply20,536   0%
> + org-agenda-get-sexps 12,332   0%
> + load-with-code-conversion 8,188   0%
> + profiler-calltree-walk8,188   0%
> + org-agenda-prepare6,482   0%
> + byte-code 4,272   0%
> + diary-font-lock-keywords  4,144   0%
> + org-agenda-list   1,114   0%
> + file-truename 1,100   0%
> + load  1,040   0%
> # On branch master
> # Changes not staged for commit:
> #   (use "git add ..." to update what will be committed)
> #   (use "git checkout -- ..." to discard changes in working 
> directory)
> #
> #modified:   lisp/org.el
> #
> no changes added to commit (use "git add" and/or "git commit -a")
> Dropped refs/stash@{0} (a8007c5e99e8481d82ec8303c75069e150a81874)
> OVERVIEW
> Setting `org-agenda-files' temporarily since "emacs -q" would overwrite 
> customizations
> File added to front of agenda file list
> CPU and memory profiler started
> 
> 12.091503858566284
>
>
> + normal-top-level 45,399,311  73%
> + command-line-16,522,990  10%
> + command-line  5,875,736   9%
> + eval  3,803,175   6%
> + progn   316,014   0%
> + let  84,388   0%
> + apply16,376   0%
> + org-agenda-get-sexps  8,188   0%
> + load-with-code-conversion 8,188   0%
> + profiler-calltree-walk8,188   0%
> + profiler-report-setup-buffer  8,188   0%
> + org-agenda-list   4,296   0%
> + diary-font-lock-keywords  4,144   0%
> + org-agenda-get-day-entries4,144   0%
> + require   3,120   0%
> + org-agenda-prepare2,338   0%
> + file-truename 2,156   0%
> + tramp-completion-file-name-handler1,040   0%
> + byte-code   104   0%

This is the equally uninteresting cpu result.

a2febd210182d9e1a37b0d7fd9ee007a10abc4bc refs/remotes/origin/HEAD
Saved working directory and index state WIP on master: a2febd2 Merge branch 
'maint'
HEAD is now at a2febd2 Merge branch 'maint'
OVERVIEW
Setting `org-agenda-files' temporarily since "emacs -q" would overwrite 
customizations
File added to front of agenda file list
CPU profiler started

12.362266302108765

+ normal-top-level   8765  78%
+ command-line   1769  15%
  Automatic GC377   3%
+ eval144   1%
+ command-line-1   68   0%
+ progn 8   0%
+ let

Re: [O] orgstruct-mode with custom headline prefix

2013-01-31 Thread Christopher Schmidt
Bastien  writes:
> PS: To make things clear: I'm confident the patch is good, but I will
> put it higher on my patch review process if I know the agenda does not
> slow down :)

Here is the patch.  Now one just needs

;; Local Variables:
;; eval: (orgstruct-mode 1)
;; orgstruct-heading-prefix-regexp: ";;; "
;; End:

It cannot get any easier than this.

2013-01-31  Christopher Schmidt  

* org.el (org-cycle-global-status, org-cycle-subtree-status): Set
state property.
(org-heading-components): Use org-heading-regexp in
orgstruct-mode.
(orgstruct-heading-prefix-regexp, orgstruct-setup-hook): New
options.
(orgstruct-initialized): New variable.
(orgstruct-mode): Simplify implementation.
(orgstruct-setup): Simplify implementation.  Translate keys to
their most general equivalent.
(orgstruct-make-binding): Generate index on the fly.  Discard
alternative keys.  Bind variables according to
orgstruct-heading-prefix-regexp.
(org-get-local-variables): Honour state property.
(org-run-like-in-org-mode): Do not override variables with
non-default values.
(org-forward-heading-same-level): Do not skip to headlines on
another level.  Handle negative prefix argument correctly.
(org-backward-heading-same-level): Use
org-forward-heading-same-level.
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6223,8 +6223,10 @@ and subscripts."
 
 (defvar org-cycle-global-status nil)
 (make-variable-buffer-local 'org-cycle-global-status)
+(put 'org-cycle-global-status 'org-state t)
 (defvar org-cycle-subtree-status nil)
 (make-variable-buffer-local 'org-cycle-subtree-status)
+(put 'org-cycle-subtree-status 'org-state t)
 
 (defvar org-inlinetask-min-level)
 
@@ -7403,13 +7405,24 @@ This is a list with the following elements:
 - the tags string, or nil."
   (save-excursion
 (org-back-to-heading t)
-(if (let (case-fold-search) (looking-at org-complex-heading-regexp))
-	(list (length (match-string 1))
-	  (org-reduced-level (length (match-string 1)))
-	  (org-match-string-no-properties 2)
-	  (and (match-end 3) (aref (match-string 3) 2))
-	  (org-match-string-no-properties 4)
-	  (org-match-string-no-properties 5)
+(if (let (case-fold-search)
+  (looking-at
+   (if orgstruct-mode
+   org-heading-regexp
+ org-complex-heading-regexp)))
+(if orgstruct-mode
+(list (length (match-string 1))
+  (org-reduced-level (length (match-string 1)))
+  nil
+  nil
+  (match-string 2)
+  nil)
+  (list (length (match-string 1))
+(org-reduced-level (length (match-string 1)))
+(org-match-string-no-properties 2)
+(and (match-end 3) (aref (match-string 3) 2))
+(org-match-string-no-properties 4)
+(org-match-string-no-properties 5))
 
 (defun org-get-entry ()
   "Get the entry text, after heading, entire subtree."
@@ -8482,12 +8495,19 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
 ;; command.  There might be problems if any of the keys is otherwise
 ;; used as a prefix key.
 
-;; Another challenge is that the key binding for TAB can be tab or \C-i,
-;; likewise the binding for RET can be return or \C-m.  Orgtbl-mode
-;; addresses this by checking explicitly for both bindings.
+(defcustom orgstruct-heading-prefix-regexp ""
+  "Regexp that matches the custom prefix of Org headlines in
+orgstruct(++)-mode."
+  :group 'org
+  :type 'string)
+;;;###autoload(put 'orgstruct-heading-prefix-regexp 'safe-local-variable 'stringp)
+
+(defcustom orgstruct-setup-hook nil
+  "Hook run after orgstruct-mode-map is filled."
+  :group 'org
+  :type 'hook)
 
-(defvar orgstruct-mode-map (make-sparse-keymap)
-  "Keymap for the minor `orgstruct-mode'.")
+(defvar orgstruct-initialized nil)
 
 (defvar org-local-vars nil
   "List of local variables, for use by `orgstruct-mode'.")
@@ -8498,26 +8518,13 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
 This mode is for using Org-mode structure commands in other
 modes.  The following keys behave as if Org-mode were active, if
 the cursor is on a headline, or on a plain list item (both as
-defined by Org-mode).
-
-M-upMove entry/item up
-M-down	Move entry/item down
-M-left	Promote
-M-right	Demote
-M-S-up	Move entry/item up
-M-S-downMove entry/item down
-M-S-leftPromote subtree
-M-S-right   Demote subtree
-M-q	Fill paragraph and items like in Org-mode
-C-c ^	Sort entries
-C-c -	Cycle list bullet
-TAB Cycle item visibility
-M-RET   Insert new heading/item
-S-M-RET Insert new TODO heading / Checkbox item
-C-c C-c Set tags / toggle checkbox"
-

Re: [O] orgstruct-mode with custom headline prefix (was: ...)

2013-01-31 Thread Christopher Schmidt
Carsten Dominik  writes:
> I was just thinking, if you are setting up two local variables, you
> could set up three and include org-outline-regexp-bol as well.  Or,
> you could just set up org-outline-regexp', and make the function
> org-struct-mode set up the other two as additional local variables.
> This would simplify things.  In fact, I think this would make for a
> more compact and better patch, Christopher, what do you think?

I agree.  I am not sure how to deduce org-heading-regexp from
org-outline-regexp, though.  Maybe we can use a buffer-local
orgstruct-heading-prefix and setup
org-heading-regexp/org-outline-regexp(-bol) from this one?

Here is my patch with org-outline-regexp-bol being a variable and being
set up by the hijacker commands using org-outline-regexp.
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -92,6 +92,7 @@
 ;; job when `orgstruct-mode' is active.
 (defvar org-outline-regexp "\\*+ "
   "Regexp to match Org headlines.")
+;;;###autoload(put 'org-outline-regexp 'safe-local-variable 'stringp)
 
 (defvar org-outline-regexp-bol "^\\*+ "
   "Regexp to match Org headlines.
@@ -101,6 +102,7 @@ sure that we are at the beginning of the line.")
 (defvar org-heading-regexp "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$"
   "Matches an headline, putting stars and text into groups.
 Stars are put in group 1 and the trimmed body in group 2.")
+;;;###autoload(put 'org-heading-regexp 'safe-local-variable 'stringp)
 
 ;; Emacs 22 calendar compatibility:  Make sure the new variables are available
 (when (fboundp 'defvaralias)
@@ -6223,8 +6225,10 @@ and subscripts."
 
 (defvar org-cycle-global-status nil)
 (make-variable-buffer-local 'org-cycle-global-status)
+(put 'org-cycle-global-status 'org-state t)
 (defvar org-cycle-subtree-status nil)
 (make-variable-buffer-local 'org-cycle-subtree-status)
+(put 'org-cycle-subtree-status 'org-state t)
 
 (defvar org-inlinetask-min-level)
 
@@ -7403,13 +7407,24 @@ This is a list with the following elements:
 - the tags string, or nil."
   (save-excursion
 (org-back-to-heading t)
-(if (let (case-fold-search) (looking-at org-complex-heading-regexp))
-	(list (length (match-string 1))
-	  (org-reduced-level (length (match-string 1)))
-	  (org-match-string-no-properties 2)
-	  (and (match-end 3) (aref (match-string 3) 2))
-	  (org-match-string-no-properties 4)
-	  (org-match-string-no-properties 5)
+(if (let (case-fold-search)
+  (looking-at
+   (if orgstruct-mode
+   org-heading-regexp
+ org-complex-heading-regexp)))
+(if orgstruct-mode
+(list (length (match-string 1))
+  (org-reduced-level (length (match-string 1)))
+  nil
+  nil
+  (match-string 2)
+  nil)
+  (list (length (match-string 1))
+(org-reduced-level (length (match-string 1)))
+(org-match-string-no-properties 2)
+(and (match-end 3) (aref (match-string 3) 2))
+(org-match-string-no-properties 4)
+(org-match-string-no-properties 5))
 
 (defun org-get-entry ()
   "Get the entry text, after heading, entire subtree."
@@ -8482,12 +8497,12 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
 ;; command.  There might be problems if any of the keys is otherwise
 ;; used as a prefix key.
 
-;; Another challenge is that the key binding for TAB can be tab or \C-i,
-;; likewise the binding for RET can be return or \C-m.  Orgtbl-mode
-;; addresses this by checking explicitly for both bindings.
+(defcustom orgstruct-setup-hook nil
+  "Hook run after orgstruct-mode-map is filled."
+  :group 'org
+  :type 'hook)
 
-(defvar orgstruct-mode-map (make-sparse-keymap)
-  "Keymap for the minor `orgstruct-mode'.")
+(defvar orgstruct-initialized nil)
 
 (defvar org-local-vars nil
   "List of local variables, for use by `orgstruct-mode'.")
@@ -8498,26 +8513,13 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
 This mode is for using Org-mode structure commands in other
 modes.  The following keys behave as if Org-mode were active, if
 the cursor is on a headline, or on a plain list item (both as
-defined by Org-mode).
-
-M-upMove entry/item up
-M-down	Move entry/item down
-M-left	Promote
-M-right	Demote
-M-S-up	Move entry/item up
-M-S-downMove entry/item down
-M-S-leftPromote subtree
-M-S-right   Demote subtree
-M-q	Fill paragraph and items like in Org-mode
-C-c ^	Sort entries
-C-c -	Cycle list bullet
-TAB Cycle item visibility
-M-RET   Insert new heading/item
-S-M-RET Insert new TODO heading / Checkbox item
-C-c C-c Set tags / toggle checkbox"
-  nil " OrgStruct" nil
-  (org-load-modules-maybe)
-  (and (orgstruct-setup) (defun orgstruct-setup () nil)))
+defined by Org-mode)."
+  nil " OrgStruct" (make-sparse-keymap)
+  (when orgstruct-mode
+(org-load-modules-maybe)
+(unless orgstru

Re: [O] orgstruct-mode with custom headline prefix

2013-01-31 Thread Bastien
Hi Christopher,

Christopher Schmidt  writes:

> All my agendas generate just fine.  I am not exactly sure how I can
> provide figures and tests.

You can instrument org with M-x elp-instrument-package RET org RET
then check the results (after running an agenda command) with 
M-x elp-results RET

You can also check with M-x profiler-start RET then get the report
with M-x profiler-report RET.

Hope that helps,

PS: To make things clear: I'm confident the patch is good, but I will
put it higher on my patch review process if I know the agenda does not
slow down :)

-- 
 Bastien



Re: [O] orgstruct-mode with custom headline prefix

2013-01-31 Thread Christopher Schmidt
Bastien  writes:

Hi Bastien,

>> Bastien  writes:
>>> Can you give an indication on how it impacts the generation of
>>> agenda?  This is a potential blocker.
>>
>> It should not impact agenda generation at all - neither feature nor
>> performance-wise.  All non-trivial changes are in parts of the code
>> that directly relate to orgstruct-mode or
>> org-\(forward\|backward\)-heading-same-level.  These functions and
>> their internals are not used non-interactively.
>
> org-outline-regexp-bol, org-\(forward\|backward\)-heading-same-level
> are fundamental vars/functions -- any change here is likely to impact
> the agenda generation.  So while I hope you're right, I'd feel better
> with figures and tests :)

org-outline-regexp-bol value is ^org-outline-regexp.  There is one place
in org where org-outline-regexp-bol is actually set -
org-with-limited-levels.  It is let-bound to (concat "^"
org-outline-regexp).

BTW what is the reason for having both org-outline-regexp and
org-outline-regexp-bol?  Matching the latter should be
faster than the former.

org-\(forward\|backward\)-heading-same-level are referenced
non-interactively in three functions - org-forward-element,
org-backward-element and org-copy-subtree.  I checked the implementation
of these functions and I did not see how the new behaviour should break
these functions.

After all, the functions now do what they are supposed to do.  Try this:

* Org
** Achim
** Bastien
** Carsten
* Diary

Place point on Achim and C-c C-b.  Place point on Casten and C-c C-f.

All my agendas generate just fine.  I am not exactly sure how I can
provide figures and tests.  We do not have any agenda test cases in the
first place.

Please take a look at the patch when you have time.  The diff is not
that scary.

Greetings,

Christopher



Re: [O] orgstruct-mode with custom headline prefix

2013-01-31 Thread Bastien
Hi Christopher,

Christopher Schmidt  writes:

> Bastien  writes:
>> Can you give an indication on how it impacts the generation of agenda?
>> This is a potential blocker.
>
> It should not impact agenda generation at all - neither feature nor
> performance-wise.  All non-trivial changes are in parts of the code that
> directly relate to orgstruct-mode or
> org-\(forward\|backward\)-heading-same-level.  These functions and their
> internals are not used non-interactively.

org-outline-regexp-bol, org-\(forward\|backward\)-heading-same-level
are fundamental vars/functions -- any change here is likely to impact
the agenda generation.  So while I hope you're right, I'd feel better
with figures and tests :)

>> Also, we won't be able to apply such a change until you assign your
>> copyright to the FSF.  I'm not asking you to go through this now
>> because I'm not sure we should apply the patch, but just to let you
>> know.
>
> I am familiar with the procedure.  The copyright of this patch goes to
> the FSF, of course, and I have FSF papers signed.

Great, I've updated worg/org-contribute.org accordingly.

Thanks!

-- 
 Bastien



Re: [O] orgstruct-mode with custom headline prefix

2013-01-31 Thread Christopher Schmidt
Bastien  writes:
> Can you give an indication on how it impacts the generation of agenda?
> This is a potential blocker.

It should not impact agenda generation at all - neither feature nor
performance-wise.  All non-trivial changes are in parts of the code that
directly relate to orgstruct-mode or
org-\(forward\|backward\)-heading-same-level.  These functions and their
internals are not used non-interactively.

> Also, we won't be able to apply such a change until you assign your
> copyright to the FSF.  I'm not asking you to go through this now
> because I'm not sure we should apply the patch, but just to let you
> know.

I am familiar with the procedure.  The copyright of this patch goes to
the FSF, of course, and I have FSF papers signed.

Christopher



Re: [O] orgstruct-mode with custom headline prefix

2013-01-30 Thread Bastien
Hi Christopher,

Christopher Schmidt  writes:

> Here is the patch, now applying cleanly on master again.

I did not have time to try the patch yet.

Can you give an indication on how it impacts the generation
of agenda?  This is a potential blocker.

Also, we won't be able to apply such a change until you
assign your copyright to the FSF.  I'm not asking you to
go through this now because I'm not sure we should apply
the patch, but just to let you know.

Thanks,

-- 
 Bastien



Re: [O] orgstruct-mode with custom headline prefix

2013-01-30 Thread Christopher Schmidt
Christopher Schmidt  writes:
> here is a patch for master that enables the use of a custom headline
> prefix file locally in conjunction with orgstruct-mode.

Here is the patch, now applying cleanly on master again.
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4437,9 +4437,9 @@ in `org-agenda-text-search-extra-files'."
 	  regexps+))
   (setq regexps+ (sort regexps+ (lambda (a b) (> (length a) (length b)
   (if (not regexps+)
-	  (setq regexp org-outline-regexp-bol)
+	  (setq regexp (org-outline-regexp-bol))
 	(setq regexp (pop regexps+))
-	(if hdl-only (setq regexp (concat org-outline-regexp-bol ".*?"
+	(if hdl-only (setq regexp (concat (org-outline-regexp-bol) ".*?"
 	  regexp
   (setq files (org-agenda-files nil 'ifmode))
   (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives)
@@ -5018,10 +5018,10 @@ of what a project is and how to check if it stuck, customize the variable
 			  "\\)\\>"))
 	 (tags (nth 2 org-stuck-projects))
 	 (tags-re (if (member "*" tags)
-		  (concat org-outline-regexp-bol
+		  (concat (org-outline-regexp-bol)
 			  (org-re ".*:[[:alnum:]_@#%]+:[ \t]*$"))
 		(if tags
-			(concat org-outline-regexp-bol
+			(concat (org-outline-regexp-bol)
 ".*:\\("
 (mapconcat 'identity tags "\\|")
 (org-re "\\):[[:alnum:]_@#%:]*[ \t]*$")
@@ -5547,7 +5547,7 @@ Do we have a reason to ignore this TODO entry because it has a time stamp?
 	  category (org-get-category b0)
 	  category-pos (get-text-property b0 'org-category-position))
 	(save-excursion
-	  (if (not (re-search-backward org-outline-regexp-bol nil t))
+	  (if (not (re-search-backward (org-outline-regexp-bol) nil t))
 	  (throw :skip nil)
 	(goto-char (match-beginning 0))
 	(if (and (eq t org-agenda-skip-timestamp-if-deadline-is-shown)
@@ -5785,7 +5785,7 @@ please use `org-class' instead."
 		 (clockp
 		  (and (looking-at ".*\n[ \t]*-[ \t]+\\([^-\n \t].*?\\)[ \t]*$")
 		   (match-string 1)
-	  (if (not (re-search-backward org-outline-regexp-bol nil t))
+	  (if (not (re-search-backward (org-outline-regexp-bol) nil t))
 	  (throw :skip nil)
 	(goto-char (match-beginning 0))
 	(setq hdmarker (org-agenda-new-marker)
@@ -6249,7 +6249,7 @@ FRACTION is what fraction of the head-warning time has passed."
 		(setq marker (org-agenda-new-marker (point)))
 		(setq category (org-get-category)
 		  category-pos (get-text-property (point) 'org-category-position))
-		(if (not (re-search-backward org-outline-regexp-bol nil t))
+		(if (not (re-search-backward (org-outline-regexp-bol) nil t))
 		(throw :skip nil)
 		  (goto-char (match-beginning 0))
 		  (setq hdmarker (org-agenda-new-marker (point))
--- a/lisp/org-ascii.el
+++ b/lisp/org-ascii.el
@@ -422,7 +422,7 @@ publishing directory."
 
 (org-init-section-numbers)
 (while (setq line (pop lines))
-  (when (and link-buffer (string-match org-outline-regexp-bol line))
+  (when (and link-buffer (string-match (org-outline-regexp-bol) line))
 	(org-export-ascii-push-links (nreverse link-buffer))
 	(setq link-buffer nil))
   (setq wrap nil)
--- a/lisp/org-colview-xemacs.el
+++ b/lisp/org-colview-xemacs.el
@@ -858,7 +858,7 @@ around it."
 	  (save-restriction
 	(narrow-to-region beg end)
 	(org-clock-sum
-  (while (re-search-forward org-outline-regexp-bol end t)
+  (while (re-search-forward (org-outline-regexp-bol) end t)
 	(if (and org-columns-skip-archived-trees
 		 (looking-at (concat ".*:" org-archive-tag ":")))
 	(org-end-of-subtree t)
@@ -1093,7 +1093,7 @@ Don't set this, this is meant for dynamic scoping.")
 (defun org-columns-compute (property)
   "Sum the values of property PROPERTY hierarchically, for the entire buffer."
   (interactive)
-  (let* ((re org-outline-regexp-bol)
+  (let* ((re (org-outline-regexp-bol))
 	 (lmax 30) ; Does anyone use deeper levels???
 	 (lvals (make-vector lmax nil))
 	 (lflag (make-vector lmax nil))
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -717,7 +717,7 @@ When COLUMNS-FMT-STRING is non-nil, use it as the column format."
 	  (save-restriction
 	(narrow-to-region beg end)
 	(org-clock-sum-today
-  (while (re-search-forward org-outline-regexp-bol end t)
+  (while (re-search-forward (org-outline-regexp-bol) end t)
 	(if (and org-columns-skip-archived-trees
 		 (looking-at (concat ".*:" org-archive-tag ":")))
 	(org-end-of-subtree t)
@@ -952,7 +952,7 @@ Don't set this, this is meant for dynamic scoping.")
 (defun org-columns-compute (property)
   "Sum the values of property PROPERTY hierarchically, for the entire buffer."
   (interactive)
-  (let* ((re org-outline-regexp-bol)
+  (let* ((re (org-outline-regexp-bol))
 	 (lmax 30) ; Does anyone use deeper levels???
 	 (lvals (make-vector lmax nil))
 	 (lflag (make-vector lmax nil))
--- a/lisp/org-docbook.el
+++ b/lisp/org-docbook.el
@@ -652,7 +652,7 @@ publishing directory."
 	(catch 'nextline
 
 	  ;; End of quote