emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: emacs-orgmode@gnu.org
Subject: Re: [RFC] Remove Org Struct mode
Date: Wed, 23 Aug 2017 10:14:17 -0500	[thread overview]
Message-ID: <87bmn6gvue.fsf@alphapapa.net> (raw)
In-Reply-To: CALn3zogZtaDfmbDEm3FZEbWXJpXyyBO1KAPbkhCnLOVEQ+NBtA@mail.gmail.com

Michael Brand <michael.ch.brand@gmail.com> writes:

Hi Michael,

> First thank you for taking over maintenance of outshine.el from
> Thorsten Jolitz.

Well, I figured it was the least I could do, since he's put so much
effort into outshine, outorg, and navi-mode over the years.  Be advised,
although I am now the maintainer, I only comprehend a tiny fraction of
them; I learn more about them when I need to fix something, which so far
has hardly happened.  :)

> How can I collapse block-indented comments like a or b in the following?:
>
> ;; * Org
> (defun foo ()
>   ;; ** a
>   (bar)
>   ;; ** b
>   (beer))
> ;; * Calc
>
> orgstruct-mode supports it with orgstruct-heading-prefix-regexp set to
> for example " *;;;* ".

I don't think this is possible, or at least not easily.  The
outline-regexp variable says:

Regular expression to match the beginning of a heading.
Any line whose beginning matches this regexp is considered to start a heading.
Note that Outline mode only checks this regexp at the start of a line,
so the regexp need not (and usually does not) start with ‘^’.

So I think you would need to modify outline-mode to do this.

However, there are other ways to fold text besides
outline/outline-minor-mode/outshine.  You could probably do it fairly
easily with the origami package.

Or you could do what I do: I modify outline-regexp and outline-level so
that the asterisks aren't even necessary.  Instead, the heading level is
set by how many semicolons there are, e.g.:

;; Regular comment
;;; Heading level 1
;;;; Heading level 2
...

Then any comment that starts with 3 or more semicolons is indented to
the left edge and becomes a collapsible heading, regardless of the
indentation of the code under it.

#+BEGIN_SRC elisp
(defun ap/el-outline-level ()
  (or
   ;; Commented outline heading
   (and (string-match (rx
		       (* space)
		       (group (one-or-more (syntax comment-start)))
		       (one-or-more space))
		      (match-string 0))
	(- (match-end 0) (match-beginning 0) 1))

   ;; Lisp def heading
   ;; Add 8 (the highest standard outline level) to every keyword
   ;; heading
   (+ 8 (- (match-end 0) (match-beginning 0)))))

(defun ap/el-mode-outline-hook ()
  (setq outline-level 'ap/el-outline-level)
  (setq outline-regexp "\\(;;[;]\\{1,8\\} \\|\\((defun\\)\\)"))
  
(add-hook 'emacs-lisp-mode-hook 'ap/el-mode-outline-hook)
#+END_SRC

It works well for me, and it doesn't even require outshine IIRC, just
outline-minor-mode.  I've tried to make this work in other languages
too, like using the number of # characters for the outline level in
shell scripts, but I failed miserably, so I use outshine for other
languages.  It's easier in elisp since Emacs already treats
triple-semicolon comments as headings.

> A bit less important for me: How can I turn off syntax highlighting of
> headings, respectively generally in outshine.el?

Well, the first thing that comes to mind is to unset the properties of
the outline-level faces, but I'm not sure if you can do that per-buffer.
So you might try removing the outline-font-lock-keywords or
outline-font-lock-faces.

Hope this helps.

Adam

  reply	other threads:[~2017-08-23 15:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-20 13:57 [RFC] Remove Org Struct mode Nicolas Goaziou
2017-08-20 14:56 ` Neil Jerram
2017-08-20 17:04 ` Scott Randby
2017-08-20 18:04 ` Eric S Fraga
2017-08-21  5:47   ` Jarmo Hurri
2017-08-22  6:58     ` Marcin Borkowski
2017-08-22  8:32       ` Eric S Fraga
2017-08-21 12:48   ` Eduardo Mercovich
2017-08-20 22:06 ` Tim Cross
2017-08-21  2:48   ` numbchild
2017-08-21 11:59 ` Michael Brand
2017-08-22 12:21   ` Kaushal Modi
2017-08-22 17:48     ` Michael Brand
2017-09-05 18:48       ` Michael Brand
2017-09-09 18:20       ` Thorsten Jolitz
2017-09-09 19:04         ` Michael Brand
2017-08-21 15:15 ` Richard Lawrence
2017-08-22 12:16 ` Kaushal Modi
2017-08-22 13:45 ` Aaron Ecay
2017-08-22 13:50 ` Carsten Dominik
2017-08-27 16:34   ` Nicolas Goaziou
2017-08-27 20:28     ` Samuel Wales
2017-08-22 22:57 ` Eric Abrahamsen
2017-08-23 10:47 ` Rasmus
2017-08-23 11:33   ` Adam Porter
2017-08-23 12:24     ` Michael Brand
2017-08-23 15:14       ` Adam Porter [this message]
2017-08-23 21:00         ` Michael Brand
2017-08-27 13:07         ` Michael Brand
2017-09-02  8:03           ` Adam Porter
2017-08-23 19:17       ` Rasmus
2017-08-23 21:02         ` Michael Brand

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=87bmn6gvue.fsf@alphapapa.net \
    --to=adam@alphapapa.net \
    --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).