* can the symbol for leading stars be changed? @ 2009-03-16 3:17 Gray Calhoun 2009-03-16 10:04 ` Tassilo Horn 0 siblings, 1 reply; 7+ messages in thread From: Gray Calhoun @ 2009-03-16 3:17 UTC (permalink / raw) To: emacs-orgmode Hi everyone, Is there a way for users to easily replace the leading stars with another symbol? In particular, I want to replace the '*' with '#' so that I use org mode to write pseduocode for R in outline form -- R uses # to designate comments and this would ensure that the headers wouldn't be read as code. I don't know emacs lisp (beyond cutting and pasting to a .emacs file), but would be happy to dive in. Thanks! --Gray -- Economics Department UC San Diego http://gray.calhoun.googlepages.com/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: can the symbol for leading stars be changed? 2009-03-16 3:17 can the symbol for leading stars be changed? Gray Calhoun @ 2009-03-16 10:04 ` Tassilo Horn 2009-03-16 19:20 ` Gray Calhoun 2009-03-16 21:22 ` Carsten Dominik 0 siblings, 2 replies; 7+ messages in thread From: Tassilo Horn @ 2009-03-16 10:04 UTC (permalink / raw) To: emacs-orgmode Gray Calhoun <gray.calhoun@gmail.com> writes: Hi Gray, > Is there a way for users to easily replace the leading stars with > another symbol? In particular, I want to replace the '*' with '#' so > that I use org mode to write pseduocode for R in outline form -- R > uses # to designate comments and this would ensure that the headers > wouldn't be read as code. I guess you want to use `orgstruct-mode' in R files, right? I also had the idea to do that, but till now I failed. As a workaround I use `outline-minor-mode' and set the `outline-regexp' to <comment-character of the language><one-or-many-stars>. Here's the code from my .emacs. --8<---------------cut here---------------start------------->8--- (defun th-outline-regexp () "Calculate the outline regexp for the current mode." (let ((comment-starter (replace-regexp-in-string "[[:space:]]+" "" comment-start))) (when (string= comment-start ";") (setq comment-starter ";;")) (concat "^" comment-starter "\\*+"))) (defun th-outline-minor-mode-init () (interactive) (setq outline-regexp (th-outline-regexp))) (add-hook 'outline-minor-mode-hook 'th-outline-minor-mode-init) --8<---------------cut here---------------end--------------->8--- I wonder if I cannot make `orgstruct-mode' work the same way. I've always thought that it uses `outline-regexp' for the cycling and stuff, but maybe I'm wrong. What's the correct regexp that's used for `org-cycle'? `org-complex-heading-regexp'? Bye, Tassilo ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re: can the symbol for leading stars be changed? 2009-03-16 10:04 ` Tassilo Horn @ 2009-03-16 19:20 ` Gray Calhoun 2009-03-16 21:22 ` Carsten Dominik 1 sibling, 0 replies; 7+ messages in thread From: Gray Calhoun @ 2009-03-16 19:20 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-orgmode Hi Tassilo, Thanks for the suggestion -- your code worked great when I loaded it on its own, but seems to be in conflict with something else in my .emacs file, so I'll have to tinker with it a little bit. This seems like an okay temporary solution, but I may look into orgstruct proper when I have some free time. Best, --Gray 2009/3/16 Tassilo Horn <tassilo@member.fsf.org>: > Gray Calhoun <gray.calhoun@gmail.com> writes: > > Hi Gray, > >> Is there a way for users to easily replace the leading stars with >> another symbol? In particular, I want to replace the '*' with '#' so >> that I use org mode to write pseduocode for R in outline form -- R >> uses # to designate comments and this would ensure that the headers >> wouldn't be read as code. > > I guess you want to use `orgstruct-mode' in R files, right? I also had > the idea to do that, but till now I failed. As a workaround I use > `outline-minor-mode' and set the `outline-regexp' to <comment-character > of the language><one-or-many-stars>. > > Here's the code from my .emacs. > > --8<---------------cut here---------------start------------->8--- > (defun th-outline-regexp () > "Calculate the outline regexp for the current mode." > (let ((comment-starter (replace-regexp-in-string > "[[:space:]]+" "" comment-start))) > (when (string= comment-start ";") > (setq comment-starter ";;")) > (concat "^" comment-starter "\\*+"))) > > (defun th-outline-minor-mode-init () > (interactive) > (setq outline-regexp (th-outline-regexp))) > > (add-hook 'outline-minor-mode-hook > 'th-outline-minor-mode-init) > --8<---------------cut here---------------end--------------->8--- > > I wonder if I cannot make `orgstruct-mode' work the same way. I've > always thought that it uses `outline-regexp' for the cycling and stuff, > but maybe I'm wrong. What's the correct regexp that's used for > `org-cycle'? `org-complex-heading-regexp'? > > Bye, > Tassilo > > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > -- Gray Calhoun Economics Department UC San Diego http://gray.calhoun.googlepages.com/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re: can the symbol for leading stars be changed? 2009-03-16 10:04 ` Tassilo Horn 2009-03-16 19:20 ` Gray Calhoun @ 2009-03-16 21:22 ` Carsten Dominik 2009-03-17 8:21 ` Orgstruct-mode with custom outline-regexp (was: can the symbol for leading stars be changed?) Tassilo Horn 1 sibling, 1 reply; 7+ messages in thread From: Carsten Dominik @ 2009-03-16 21:22 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-orgmode On Mar 16, 2009, at 11:04 AM, Tassilo Horn wrote: > Gray Calhoun <gray.calhoun@gmail.com> writes: > > Hi Gray, > >> Is there a way for users to easily replace the leading stars with >> another symbol? In particular, I want to replace the '*' with '#' so >> that I use org mode to write pseduocode for R in outline form -- R >> uses # to designate comments and this would ensure that the headers >> wouldn't be read as code. > > I guess you want to use `orgstruct-mode' in R files, right? I also > had > the idea to do that, but till now I failed. As a workaround I use > `outline-minor-mode' and set the `outline-regexp' to <comment- > character > of the language><one-or-many-stars>. > > Here's the code from my .emacs. > > --8<---------------cut here---------------start------------->8--- > (defun th-outline-regexp () > "Calculate the outline regexp for the current mode." > (let ((comment-starter (replace-regexp-in-string > "[[:space:]]+" "" comment-start))) > (when (string= comment-start ";") > (setq comment-starter ";;")) > (concat "^" comment-starter "\\*+"))) > > (defun th-outline-minor-mode-init () > (interactive) > (setq outline-regexp (th-outline-regexp))) > > (add-hook 'outline-minor-mode-hook > 'th-outline-minor-mode-init) > --8<---------------cut here---------------end--------------->8--- > > I wonder if I cannot make `orgstruct-mode' work the same way. I've > always thought that it uses `outline-regexp' for the cycling and > stuff, > but maybe I'm wrong. What's the correct regexp that's used for > `org-cycle'? `org-complex-heading-regexp'? org-cycle does use outline-regexp, so this will work fine. However, for much other functionality, including demotion and promotion, stars are hard-coded. - Carsten ^ permalink raw reply [flat|nested] 7+ messages in thread
* Orgstruct-mode with custom outline-regexp (was: can the symbol for leading stars be changed?) 2009-03-16 21:22 ` Carsten Dominik @ 2009-03-17 8:21 ` Tassilo Horn 2009-03-17 10:48 ` Carsten Dominik 0 siblings, 1 reply; 7+ messages in thread From: Tassilo Horn @ 2009-03-17 8:21 UTC (permalink / raw) To: emacs-orgmode Carsten Dominik <dominik@science.uva.nl> writes: Hi Carsten, >> I wonder if I cannot make `orgstruct-mode' work the same way. I've >> always thought that it uses `outline-regexp' for the cycling and >> stuff, but maybe I'm wrong. What's the correct regexp that's used >> for `org-cycle'? `org-complex-heading-regexp'? > > org-cycle does use outline-regexp, so this will work fine. Hm, it does work with "M-x org-cycle" (then it toggles between FOLDED and CHILDREN, but not SUBTREE), but with TAB nothing happens. ,---- | <tab> runs the command orgstruct-hijacker-command-102, which is an interactive | Lisp function. | | It is bound to <tab>. | | (orgstruct-hijacker-command-102 arg) | | In Structure, run `org-cycle'. | Outside of structure, run the binding of `[(tab)]' or ` '. `---- Here's the test file: --8<---------------cut here---------------start------------->8--- ;;* Heading 1 (setq foo 1) ;;** SubHeading 1.1 (+ 1 1) ;; test ;;** SubHeading 1.2 (defun foo () nil) ;;* Heading 2 (defun bar () nil) ;;** SubHeading 2.1 (+ 7 7) --8<---------------cut here---------------end--------------->8--- When I hit C-c C-c which should allow setting tags, it tells me org-ctrl-c-ctrl-c: C-c C-c can do nothing useful at this location. although I'm on a headline and the value of outline regexp is: ,---- | outline-regexp is a variable defined in `outline.el'. | Its value is ";;[*]+ " | Local in buffer test.el; global value is "[*\f]+" `---- The only thing that comes into my mind is that those hijacker commands use a hardcoded outline-regexp or an earlier value of outline-regexp. Yeah, that seems to be the case. When I use only stars, the key bindings work. Carsten, could you change that, so that the hijackers use the current value of outline-regexp? > However, for much other functionality, including demotion and > promotion, stars are hard-coded. Cycling would be more than enough for me. I just want to have a good structure in my code files where I can easily toggle the visibility. Basically, `outline-minor-mode' does what I want, but org cycling is still better. Bye, Tassilo -- Chuck Norris sheds his skin twice a year. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Orgstruct-mode with custom outline-regexp (was: can the symbol for leading stars be changed?) 2009-03-17 8:21 ` Orgstruct-mode with custom outline-regexp (was: can the symbol for leading stars be changed?) Tassilo Horn @ 2009-03-17 10:48 ` Carsten Dominik 2009-03-17 12:00 ` Orgstruct-mode with custom outline-regexp Tassilo Horn 0 siblings, 1 reply; 7+ messages in thread From: Carsten Dominik @ 2009-03-17 10:48 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-orgmode Hi Tassilo, you are right, it does not work with orgstruct-mode, because that sets local variables like in Org-mode for the duration of the command. I think the best solution in this case, where you want to do mainly visibility cycling in an arbitrary mode is using outline-minor-mode and bind org-cycle to some convenient command. There is a FAQ which describes a setup for this, "Can I get the visibility-cycling features in outline-mode and outline- minor-mode?" - Carsten On Mar 17, 2009, at 9:21 AM, Tassilo Horn wrote: > Carsten Dominik <dominik@science.uva.nl> writes: > > Hi Carsten, > >>> I wonder if I cannot make `orgstruct-mode' work the same way. I've >>> always thought that it uses `outline-regexp' for the cycling and >>> stuff, but maybe I'm wrong. What's the correct regexp that's used >>> for `org-cycle'? `org-complex-heading-regexp'? >> >> org-cycle does use outline-regexp, so this will work fine. > > Hm, it does work with "M-x org-cycle" (then it toggles between FOLDED > and CHILDREN, but not SUBTREE), but with TAB nothing happens. > > ,---- > | <tab> runs the command orgstruct-hijacker-command-102, which is an > interactive > | Lisp function. > | > | It is bound to <tab>. > | > | (orgstruct-hijacker-command-102 arg) > | > | In Structure, run `org-cycle'. > | Outside of structure, run the binding of `[(tab)]' or ` '. > `---- > > Here's the test file: > > --8<---------------cut here---------------start------------->8--- > ;;* Heading 1 > > (setq foo 1) > > ;;** SubHeading 1.1 > > (+ 1 1) ;; test > > ;;** SubHeading 1.2 > > (defun foo () nil) > > ;;* Heading 2 > > (defun bar () nil) > > ;;** SubHeading 2.1 > > (+ 7 7) > --8<---------------cut here---------------end--------------->8--- > > When I hit C-c C-c which should allow setting tags, it tells me > > org-ctrl-c-ctrl-c: C-c C-c can do nothing useful at this location. > > although I'm on a headline and the value of outline regexp is: > > ,---- > | outline-regexp is a variable defined in `outline.el'. > | Its value is ";;[*]+ " > | Local in buffer test.el; global value is "[*\f]+" > `---- > > The only thing that comes into my mind is that those hijacker commands > use a hardcoded outline-regexp or an earlier value of outline-regexp. > Yeah, that seems to be the case. When I use only stars, the key > bindings work. > > Carsten, could you change that, so that the hijackers use the current > value of outline-regexp? > >> However, for much other functionality, including demotion and >> promotion, stars are hard-coded. > > Cycling would be more than enough for me. I just want to have a good > structure in my code files where I can easily toggle the visibility. > Basically, `outline-minor-mode' does what I want, but org cycling is > still better. > > Bye, > Tassilo > -- > Chuck Norris sheds his skin twice a year. > > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Orgstruct-mode with custom outline-regexp 2009-03-17 10:48 ` Carsten Dominik @ 2009-03-17 12:00 ` Tassilo Horn 0 siblings, 0 replies; 7+ messages in thread From: Tassilo Horn @ 2009-03-17 12:00 UTC (permalink / raw) To: emacs-orgmode Carsten Dominik <dominik@science.uva.nl> writes: Hi Carsten, > you are right, it does not work with orgstruct-mode, because that sets > local variables like in Org-mode for the duration of the command. > > I think the best solution in this case, where you want to do mainly > visibility cycling in an arbitrary mode is using outline-minor-mode > and bind org-cycle to some convenient command. Ok, then I'll stay with this approach. > There is a FAQ which describes a setup for this, > > "Can I get the visibility-cycling features in outline-mode and outline- > minor-mode?" Thanks for the pointer. Bye, Tassilo ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-03-17 12:00 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-03-16 3:17 can the symbol for leading stars be changed? Gray Calhoun 2009-03-16 10:04 ` Tassilo Horn 2009-03-16 19:20 ` Gray Calhoun 2009-03-16 21:22 ` Carsten Dominik 2009-03-17 8:21 ` Orgstruct-mode with custom outline-regexp (was: can the symbol for leading stars be changed?) Tassilo Horn 2009-03-17 10:48 ` Carsten Dominik 2009-03-17 12:00 ` Orgstruct-mode with custom outline-regexp Tassilo Horn
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).