* program outlining
@ 2016-07-11 12:59 Rusi
2016-07-11 13:48 ` Kaushal Modi
` (7 more replies)
0 siblings, 8 replies; 17+ messages in thread
From: Rusi @ 2016-07-11 12:59 UTC (permalink / raw)
To: help-gnu-emacs
Ive been trying to figure out the best outlining that emacs can give for
programs.
Outline-mode seems to be more for text than code
Outshine mode inspired by above+org-mode seemed promising in that it seems to
make org mode's wonderful TAB-behavior work for code.
But I couldn’t get it to work
So hideshow…
But hideshow keystrokes are clumsy
Even with the suggestions of
http://stackoverflow.com/questions/791539/how-can-i-have-folds-for-c-java-in-emacs
to do
(add-hook 'c-mode-common-hook
(lambda()
(local-set-key (kbd "C-c <right>") 'hs-show-block)
(local-set-key (kbd "C-c <left>") 'hs-hide-block)
(local-set-key (kbd "C-c <up>") 'hs-hide-all)
(local-set-key (kbd "C-c <down>") 'hs-show-all)
(hs-minor-mode t)))
its better than the builtin defaults but not nearly as neat as org's
all-purpose TAB and Shift-TAB.
Is it so hard to do org's TAB cycling
ie hs-show-block and hs-hide-block on the same key in cycle?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 12:59 program outlining Rusi
@ 2016-07-11 13:48 ` Kaushal Modi
[not found] ` <mailman.1089.1468244895.26859.help-gnu-emacs@gnu.org>
` (6 subsequent siblings)
7 siblings, 0 replies; 17+ messages in thread
From: Kaushal Modi @ 2016-07-11 13:48 UTC (permalink / raw)
To: Rusi, help-gnu-emacs
Outshine works fine for me, along with the TAB and s-TAB (<backtab>)
behavior, and I use it everyday in emacs-lisp-mode and other modes like
shell-script-mode and verilog-mode.
Here's my outshine setup:
https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-outshine.el
If you ignore the 'modi/outline-toc' function definition in the above link,
there's very little configuration I need to do for outshine. The only
important config is to set the outline-minor-mode-prefix and adding
outshine-hook-function to outline-minor-mode-hook.
On Mon, Jul 11, 2016, 9:00 AM Rusi <rustompmody@gmail.com> wrote:
> Outshine mode inspired by above+org-mode seemed promising in that it seems
> to
> make org mode's wonderful TAB-behavior work for code.
> But I couldn’t get it to work
>
--
--
Kaushal Modi
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
[not found] ` <mailman.1089.1468244895.26859.help-gnu-emacs@gnu.org>
@ 2016-07-11 14:12 ` Rusi
2016-07-11 14:34 ` Rusi
2016-07-11 14:59 ` Kaushal Modi
0 siblings, 2 replies; 17+ messages in thread
From: Rusi @ 2016-07-11 14:12 UTC (permalink / raw)
To: help-gnu-emacs
On Monday, July 11, 2016 at 7:18:18 PM UTC+5:30, Kaushal Modi wrote:
> Outshine works fine for me, along with the TAB and s-TAB (<backtab>)
> behavior, and I use it everyday in emacs-lisp-mode and other modes like
> shell-script-mode and verilog-mode.
>
> Here's my outshine setup:
> https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-outshine.el
>
> If you ignore the 'modi/outline-toc' function definition in the above link,
> there's very little configuration I need to do for outshine. The only
> important config is to set the outline-minor-mode-prefix and adding
> outshine-hook-function to outline-minor-mode-hook.
Looks impressive
How does it work?
Which modes?
I can load this file alright
But thereafter outshine is so undocumented that I dont know what next
On a different note does outshine understand programming language syntax?
Or does it need addition of org-style 'cookies'?
Because if latter its not much use for arbitrary codebases
(which hideshow seems to handle at least somewhat)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 14:12 ` Rusi
@ 2016-07-11 14:34 ` Rusi
2016-07-11 14:59 ` Kaushal Modi
1 sibling, 0 replies; 17+ messages in thread
From: Rusi @ 2016-07-11 14:34 UTC (permalink / raw)
To: help-gnu-emacs
On Monday, July 11, 2016 at 7:42:10 PM UTC+5:30, Rusi wrote:
> On Monday, July 11, 2016 at 7:18:18 PM UTC+5:30, Kaushal Modi wrote:
> > Outshine works fine for me, along with the TAB and s-TAB (<backtab>)
> > behavior, and I use it everyday in emacs-lisp-mode and other modes like
> > shell-script-mode and verilog-mode.
> >
> > Here's my outshine setup:
> > https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-outshine.el
> >
> > If you ignore the 'modi/outline-toc' function definition in the above link,
> > there's very little configuration I need to do for outshine. The only
> > important config is to set the outline-minor-mode-prefix and adding
> > outshine-hook-function to outline-minor-mode-hook.
>
>
>
> Looks impressive
> How does it work?
> Which modes?
>
> I can load this file alright
> But thereafter outshine is so undocumented that I dont know what next
>
> On a different note does outshine understand programming language syntax?
> Or does it need addition of org-style 'cookies'?
> Because if latter its not much use for arbitrary codebases
> (which hideshow seems to handle at least somewhat)
I guess the closest to what is required is org-hideshow.
On first trial seems to work though a bit bitrotten
Here's an extract showing its a bit out of date
===============================
(defmacro hs-org/define-keys ()
`(progn
,@(mapcar (lambda (key) `(hs-org/define-key ,key hs-org/hideshow)) hs-org/trigger-keys-block)
,@(mapcar (lambda (key) `(hs-org/define-key ,key hs-org/hideshow-all)) hs-org/trigger-keys-all)
))
;; No closures is killing me!
(defmacro hs-org/define-key (key function)
`(define-key hs-org/minor-mode-map ,key (lambda () (interactive)
(,function ,key))))
=================================
I guess the “no closures” gripe is not true after lexical binding??
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 12:59 program outlining Rusi
2016-07-11 13:48 ` Kaushal Modi
[not found] ` <mailman.1089.1468244895.26859.help-gnu-emacs@gnu.org>
@ 2016-07-11 14:53 ` Eli Zaretskii
2016-07-11 15:13 ` Robert Thorpe
` (4 subsequent siblings)
7 siblings, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2016-07-11 14:53 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Mon, 11 Jul 2016 05:59:59 -0700 (PDT)
> From: Rusi <rustompmody@gmail.com>
>
> Ive been trying to figure out the best outlining that emacs can give for
> programs.
Did you try selective-display (C-x $)?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 14:12 ` Rusi
2016-07-11 14:34 ` Rusi
@ 2016-07-11 14:59 ` Kaushal Modi
1 sibling, 0 replies; 17+ messages in thread
From: Kaushal Modi @ 2016-07-11 14:59 UTC (permalink / raw)
To: Rusi, help-gnu-emacs
On Mon, Jul 11, 2016 at 10:19 AM Rusi <rustompmody@gmail.com> wrote:
> How does it work?
>
That's a very broad question. Here's an attempt to quickly explain this.
outshine mode works by piggybacking on outline-minor-mode. So you enable
outline-minor-mode where you want outshine to work.
> Which modes?
>
I already have that in my posted outshine config:
(defvar modi/outline-minor-mode-hooks '(verilog-mode-hook
emacs-lisp-mode-hook
conf-space-mode-hook) ; for
.tmux.conf
"List of hooks of major modes in which `outline-minor-mode' should be
enabled.")
> I can load this file alright
>
Loading just this file will *not* work. There are dependencies in it on my
minor mode, and probably other things too. It's part of my whole config. So
I wouldn't expect it to work independently.
> But thereafter outshine is so undocumented that I dont know what next
>
I found the documentation here to be adequate:
https://github.com/tj64/outshine#installation
You need to pose specific questions.. Check for yourself if the outshine
mode is getting enabled when it should (when you enable outline-minor-mode
in any major mode)
On a different note does outshine understand programming language syntax?
>
It uses a major-mode's comment syntax to detect headlines.
For emacs-lisp-mode,
;;; heading level 1
;;;; heading level 2
;;;;; heading level 3
For all other modes, it detects org-like heading syntax with that
major-mode's comment chars as prefix.
For verilog-mode,
// * heading level 1
// ** heading level 2
// *** heading level 3
For shell-script-mode,
# * heading level 1
# ** heading level 2
# *** heading level 3
> Or does it need addition of org-style 'cookies'?
>
(as explained above)
> Because if latter its not much use for arbitrary codebases
>
Yes, outshine does need adding special syntax headings as shown above. If
you are able to add those, and others in your team do not mind it, do it.
Because for everyone not using emacs/outshine, they are as good as regular
comments and it will not affect the code's functionality.
> (which hideshow seems to handle at least somewhat)
>
This boils down to personal preference. I like outshine syntax because it
brings in many more org-like commands (not just visibility cycling). I can
even promote/demote sections, move them up/down, mark/comment whole
sections, etc. Also I can automatically parse a file and auto-generate a
contents section (like this:
https://github.com/kaushalmodi/.emacs.d/blob/3bfb3faa76653c4d36317359f477707bf31c6082/setup-files/setup-editing.el#L4-L42
)
If all you need is code folding, then outshine is most likely an overkill.
I have experimented with a lot of code folding methods. For pure code
folding, I end up using a hybrid of fold-this (3rd party package),
set-selective-display (inbuilt) and yafolding (3rd party package) wrapped
in my modi/fold-dwim command (config:
https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-fold.el
).
Ignoring all that, the simply thing to try would be to try just the
fold-this package.
--
--
Kaushal Modi
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 12:59 program outlining Rusi
` (2 preceding siblings ...)
2016-07-11 14:53 ` Eli Zaretskii
@ 2016-07-11 15:13 ` Robert Thorpe
2016-07-11 15:21 ` Emanuel Berg
` (3 subsequent siblings)
7 siblings, 0 replies; 17+ messages in thread
From: Robert Thorpe @ 2016-07-11 15:13 UTC (permalink / raw)
To: Rusi; +Cc: help-gnu-emacs
Rusi <rustompmody@gmail.com> writes:
> Ive been trying to figure out the best outlining that emacs can give for
> programs.
>
> Outline-mode seems to be more for text than code
> Outshine mode inspired by above+org-mode seemed promising in that it seems to
> make org mode's wonderful TAB-behavior work for code.
> But I couldn’t get it to work
>
> So hideshow…
> But hideshow keystrokes are clumsy
There's a difference between personal code and shared code here.
The outline based modes require additions to the code to be made in the
right way. Making that work with shared code when other people are
using different editors is difficult. Even if the other programmers use
Emacs, many Emacs users don't use these modes. This is not a problem if
it's personal code.
Hide/show, selective display and pages are more general tools. They
require little or nothing to be embedded in the code itself. But, in
many cases an automatically generated navigation tree can't beat a
manually created one.
So, there's no one best way.
BR,
Robert Thorpe
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 12:59 program outlining Rusi
` (3 preceding siblings ...)
2016-07-11 15:13 ` Robert Thorpe
@ 2016-07-11 15:21 ` Emanuel Berg
2016-07-11 18:07 ` Rusi
[not found] ` <mailman.1101.1468248815.26859.help-gnu-emacs@gnu.org>
` (2 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Emanuel Berg @ 2016-07-11 15:21 UTC (permalink / raw)
To: help-gnu-emacs
Rusi <rustompmody@gmail.com> writes:
> Ive been trying to figure out the best
> outlining that emacs can give for programs.
"outlining for programs"?
You mean how to jump around all the files -
source, data, Makefile, documentation, and
so on?
--
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
- so far: 56 Blogomatic articles -
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
[not found] ` <mailman.1101.1468248815.26859.help-gnu-emacs@gnu.org>
@ 2016-07-11 18:05 ` Rusi
0 siblings, 0 replies; 17+ messages in thread
From: Rusi @ 2016-07-11 18:05 UTC (permalink / raw)
To: help-gnu-emacs
On Monday, July 11, 2016 at 8:23:38 PM UTC+5:30, Eli Zaretskii wrote:
> > Date: Mon, 11 Jul 2016 05:59:59 -0700 (PDT)
> > From: Rusi
> >
> > Ive been trying to figure out the best outlining that emacs can give for
> > programs.
>
> Did you try selective-display (C-x $)?
Not bad for a start – thanks
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 15:21 ` Emanuel Berg
@ 2016-07-11 18:07 ` Rusi
2016-07-11 18:36 ` Emanuel Berg
0 siblings, 1 reply; 17+ messages in thread
From: Rusi @ 2016-07-11 18:07 UTC (permalink / raw)
To: help-gnu-emacs
On Monday, July 11, 2016 at 8:51:31 PM UTC+5:30, Emanuel Berg wrote:
> Rusi writes:
>
> > Ive been trying to figure out the best
> > outlining that emacs can give for programs.
>
> "outlining for programs"?
>
> You mean how to jump around all the files -
> source, data, Makefile, documentation, and
> so on?
>
https://en.wikipedia.org/wiki/Folding_editor
[not claiming its a great reference!]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 18:07 ` Rusi
@ 2016-07-11 18:36 ` Emanuel Berg
2016-07-13 12:49 ` Rusi
0 siblings, 1 reply; 17+ messages in thread
From: Emanuel Berg @ 2016-07-11 18:36 UTC (permalink / raw)
To: help-gnu-emacs
Rusi <rustompmody@gmail.com> writes:
> https://en.wikipedia.org/wiki/Folding_editor
> [not claiming its a great reference!]
OK, here is a good reference tho:
http://en.writecheck.com/6-reasons-to-write-in-your-own-words/
--
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
- so far: 56 Blogomatic articles -
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 12:59 program outlining Rusi
` (5 preceding siblings ...)
[not found] ` <mailman.1101.1468248815.26859.help-gnu-emacs@gnu.org>
@ 2016-07-13 1:44 ` Howard Melman
2016-07-13 2:00 ` Drew Adams
[not found] ` <mailman.1250.1468374265.26859.help-gnu-emacs@gnu.org>
7 siblings, 1 reply; 17+ messages in thread
From: Howard Melman @ 2016-07-13 1:44 UTC (permalink / raw)
To: help-gnu-emacs
I use outline-minor-mode in emacs-lisp mode and do:
(setq outline-regexp ";;;;? \\|(....")
This tracks ;;; and ;;;; comments and also
lines beginning with a ( and four more characters.
Works pretty well. I haven't tried finding values for
outline-regexp in other programming modes.
Then I add:
(define-key outline-minor-mode-map (kbd "C-<tab>") 'org-cycle)
(define-key outline-minor-mode-map (kbd "S-<tab>") 'org-global-cycle)))
Honestly, outline-mode and outline-minor-mode should
just duplicate the org-cycle commands.
--
Howard
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: program outlining
2016-07-13 1:44 ` Howard Melman
@ 2016-07-13 2:00 ` Drew Adams
0 siblings, 0 replies; 17+ messages in thread
From: Drew Adams @ 2016-07-13 2:00 UTC (permalink / raw)
To: Howard Melman, help-gnu-emacs
> Honestly, outline-mode and outline-minor-mode should
> just duplicate the org-cycle commands.
`M-x report-emacs-bug' for enhancement requests.
(The code could easily substitute Org key bindings whenever
Org has been loaded. Or you can just continue to do that as
an individual user.)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
[not found] ` <mailman.1250.1468374265.26859.help-gnu-emacs@gnu.org>
@ 2016-07-13 2:47 ` Rusi
2016-07-13 13:42 ` Howard Melman
0 siblings, 1 reply; 17+ messages in thread
From: Rusi @ 2016-07-13 2:47 UTC (permalink / raw)
To: help-gnu-emacs
On Wednesday, July 13, 2016 at 7:14:27 AM UTC+5:30, Howard Melman wrote:
> I use outline-minor-mode in emacs-lisp mode and do:
>
> (setq outline-regexp ";;;;? \\|(....")
This would be serious if we could have it mode-specific
eg "///" for C++
"/***" for C which (I guess?) needs to be coded up as "/\\*\\*\\*"
??
Two related threads that unfortunately died:
https://lists.gnu.org/archive/html/emacs-devel/2006-12/msg00232.html
http://comments.gmane.org/gmane.emacs.orgmode/67871
Personally with ASCII being superseded by Unicode I find it strange to have
a star '*' and that too hardcoded.
>
> This tracks ;;; and ;;;; comments and also
> lines beginning with a ( and four more characters.
> Works pretty well. I haven't tried finding values for
> outline-regexp in other programming modes.
>
> Then I add:
>
> (define-key outline-minor-mode-map (kbd "C-<tab>") 'org-cycle)
> (define-key outline-minor-mode-map (kbd "S-<tab>") 'org-global-cycle)))
>
> Honestly, outline-mode and outline-minor-mode should
> just duplicate the org-cycle commands.
>
> --
>
> Howard
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-11 18:36 ` Emanuel Berg
@ 2016-07-13 12:49 ` Rusi
2016-07-13 13:31 ` Emanuel Berg
0 siblings, 1 reply; 17+ messages in thread
From: Rusi @ 2016-07-13 12:49 UTC (permalink / raw)
To: help-gnu-emacs
On Tuesday, July 12, 2016 at 12:06:11 AM UTC+5:30, Emanuel Berg wrote:
> Rusi writes:
>
> > https://en.wikipedia.org/wiki/Folding_editor
> > [not claiming its a great reference!]
>
> OK, here is a good reference tho:
>
> http://en.writecheck.com/6-reasons-to-write-in-your-own-words/
As a matter of fact it was targeted to some notes I was making for my students
on starting to use emacs
Still rough but this is what is…
http://blog.languager.org/2016/07/emacs-tips.html
[search for ‘folding’]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-13 12:49 ` Rusi
@ 2016-07-13 13:31 ` Emanuel Berg
0 siblings, 0 replies; 17+ messages in thread
From: Emanuel Berg @ 2016-07-13 13:31 UTC (permalink / raw)
To: help-gnu-emacs
Rusi <rustompmody@gmail.com> writes:
> As a matter of fact it was targeted to some
> notes I was making for my students on
> starting to use emacs
>
> Still rough but this is what is…
>
> http://blog.languager.org/2016/07/emacs-tips.html
> [search for ‘folding’]
... you mean this? What about it?
Folding
* Selective display C-x $ simple and works; not great
* HideShow improve the keys with suggestions
* Outshine (badly documented)
* speedbar; its appearance
* ECB
--
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
- so far: 57 Blogomatic articles -
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: program outlining
2016-07-13 2:47 ` Rusi
@ 2016-07-13 13:42 ` Howard Melman
0 siblings, 0 replies; 17+ messages in thread
From: Howard Melman @ 2016-07-13 13:42 UTC (permalink / raw)
To: help-gnu-emacs
Rusi <rustompmody@gmail.com> writes:
> On Wednesday, July 13, 2016 at 7:14:27 AM UTC+5:30, Howard Melman wrote:
>> I use outline-minor-mode in emacs-lisp mode and do:
>>
>> (setq outline-regexp ";;;;? \\|(....")
>
> This would be serious if we could have it mode-specific
> eg "///" for C++
> "/***" for C which (I guess?) needs to be coded up as "/\\*\\*\\*"
> ??
That of course should have been:
(setq-local outline-regexp ";;;;? \\|(....")
--
Howard
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2016-07-13 13:42 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-11 12:59 program outlining Rusi
2016-07-11 13:48 ` Kaushal Modi
[not found] ` <mailman.1089.1468244895.26859.help-gnu-emacs@gnu.org>
2016-07-11 14:12 ` Rusi
2016-07-11 14:34 ` Rusi
2016-07-11 14:59 ` Kaushal Modi
2016-07-11 14:53 ` Eli Zaretskii
2016-07-11 15:13 ` Robert Thorpe
2016-07-11 15:21 ` Emanuel Berg
2016-07-11 18:07 ` Rusi
2016-07-11 18:36 ` Emanuel Berg
2016-07-13 12:49 ` Rusi
2016-07-13 13:31 ` Emanuel Berg
[not found] ` <mailman.1101.1468248815.26859.help-gnu-emacs@gnu.org>
2016-07-11 18:05 ` Rusi
2016-07-13 1:44 ` Howard Melman
2016-07-13 2:00 ` Drew Adams
[not found] ` <mailman.1250.1468374265.26859.help-gnu-emacs@gnu.org>
2016-07-13 2:47 ` Rusi
2016-07-13 13:42 ` Howard Melman
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.