all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* how to set outline-minor-mode heading levels in outline-regexp
@ 2015-03-22  2:14 Qiang Fang
  2015-03-24  6:57 ` Michael Heerdegen
  0 siblings, 1 reply; 2+ messages in thread
From: Qiang Fang @ 2015-03-22  2:14 UTC (permalink / raw)
  To: help-gnu-emacs

I am trying to add a custom heading to program mode, and I want it to be on
the highest level and move all other levels down, so I can add more
structure to my long script. For example, for python mode, the heading
format is  "# *", the number of star determines its level.
My approach is to modify the outline-regexp variable by add a hook like this.

    (defun my_heading()
    "custom heading for all prog mode"
    (setq outline-regexp (concat "\\(?:" comment-start " [*]\\{1,8\\}\\)?"
outline-regexp)))
    (add-hook 'outline-minor-mode-hook 'my_heading)

Ideally, the smaller the match, the higher the level of the heading. But the
above doesn't work. If I replace it with the following one, it doesn't work
either.

    (setq outline-regexp (concat comment-start " [*]\\{1,8\\}\\|"
outline-regexp)))

The value of the original outline-regexp for python mode is 

"[[:space:]]*\\_<\\(?:\\(?:class\\|def\\|e\\(?:l\\(?:if\\|se\\)\\|xcept\\)\\|f\\
(?:inally\\|or\\)\\|if\\|try\\|w\\(?:hile\\|ith\\)\\)\\)\\_>"

Can anyone please tell me how can I achieve my goal?
Thank you in advance.




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

* Re: how to set outline-minor-mode heading levels in outline-regexp
  2015-03-22  2:14 how to set outline-minor-mode heading levels in outline-regexp Qiang Fang
@ 2015-03-24  6:57 ` Michael Heerdegen
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Heerdegen @ 2015-03-24  6:57 UTC (permalink / raw)
  To: Qiang Fang; +Cc: help-gnu-emacs

Qiang Fang <godblessfq@gmail.com> writes:

>     (setq outline-regexp (concat comment-start " [*]\\{1,8\\}\\|"
> outline-regexp)))

(setq outline-regexp (concat some-regexp... outline-regexp)) doesn't make
sense to me.  Why do you append the old binding of the variable to your
new setting?

Also, you usage of `comment-start' is not correct.  This regexp does not
necessarily match the complete comment start delimiter.  For example, in
Emacs Lisp, `comment-start' is bound to ";", so your setting of
`outline-regexp' will not work for comments starting with more than one
semicolon.  AFAICT, `comment-start' can even be nil for some modes.


HTH,

Michael.



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

end of thread, other threads:[~2015-03-24  6:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-22  2:14 how to set outline-minor-mode heading levels in outline-regexp Qiang Fang
2015-03-24  6:57 ` Michael Heerdegen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.