* viewing number of nested headlines
@ 2013-02-04 23:59 42 147
2013-02-05 10:39 ` Bastien
0 siblings, 1 reply; 10+ messages in thread
From: 42 147 @ 2013-02-04 23:59 UTC (permalink / raw
To: Org Mode
[-- Attachment #1: Type: text/plain, Size: 118 bytes --]
Is there a way to see how many nested headlines there are within a
higher-level headline (not necessarily top-level)?
[-- Attachment #2: Type: text/html, Size: 125 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: viewing number of nested headlines
2013-02-04 23:59 viewing number of nested headlines 42 147
@ 2013-02-05 10:39 ` Bastien
2013-02-05 12:43 ` François Pinard
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Bastien @ 2013-02-05 10:39 UTC (permalink / raw
To: 42 147; +Cc: Org Mode
42 147 <aeuster@gmail.com> writes:
> Is there a way to see how many nested headlines there are within a
> higher-level headline (not necessarily top-level)?
This is a nice feature of VimOrganizer but no, there is no way to do
this with Org for now.
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: viewing number of nested headlines
2013-02-05 10:39 ` Bastien
@ 2013-02-05 12:43 ` François Pinard
2013-02-05 18:34 ` Samuel Wales
2013-02-05 13:25 ` Sebastien Vauban
2013-02-05 20:17 ` 42 147
2 siblings, 1 reply; 10+ messages in thread
From: François Pinard @ 2013-02-05 12:43 UTC (permalink / raw
To: emacs-orgmode
Bastien <bzg@altern.org> writes:
> 42 147 <aeuster@gmail.com> writes:
>> Is there a way to see how many nested headlines there are within a
>> higher-level headline (not necessarily top-level)?
> This is a nice feature of VimOrganizer but no, there is no way to do
> this with Org for now.
Hi!
I'm not sure the following code responds to your wish, maybe it would
help enough? Surely, it is often useful to me. You might have to
adapt the first few lines to your local installation or taste, however.
(defvar fp-org-distribution "~/emacs/_/org-mode")
(add-to-list 'load-path (concat fp-org-distribution "/lisp"))
(add-to-list 'load-path (concat fp-org-distribution "/contrib/lisp" ) t)
(require 'org)
(defface fp-warn-face
'((((class color) (background light))
(:foreground "chocolate2" :weight bold))
(((class color) (background dark))
(:foreground "chocolate1" :weight bold)))
"Face for own highlights.")
(define-key org-mode-map "\C-cow" 'fp-org-weight-display)
(defun fp-org-weight-display ()
"Show header weights in the entire buffer.
Use \\[fp-org-weight-remove-overlays] to remove the header weights."
(interactive)
(fp-org-weight-remove-overlays)
(save-excursion
(goto-char (point-min))
(outline-next-visible-heading 1)
(while (not (eobp))
(save-excursion
(fp-org-weight-put-overlay (fp-org-weights-at-point)
(funcall outline-level)))
(outline-next-visible-heading 1))
;; Arrange to remove the overlays upon next change.
(when org-remove-highlights-with-change
(org-add-hook 'before-change-functions 'fp-org-weight-remove-overlays
nil 'local))))
(defvar fp-org-weight-overlays nil)
(make-variable-buffer-local 'fp-org-weight-overlays)
(defun fp-org-weight-put-overlay (weights &optional level)
"Put an overlays on the current line, displaying WEIGHTS.
If LEVEL is given, prefix weights with a corresponding number of stars.
This creates a new overlay and stores it in `fp-org-weight-overlays', so that it
will be easy to remove."
(let* ((h (car weights))
(p (cdr weights))
(c 50)
(l (if level (org-get-valid-level level 0) 0))
(off 0))
(org-move-to-column c)
(unless (eolp) (skip-chars-backward "^ \t"))
(skip-chars-backward " \t")
(let* ((ov (make-overlay (1- (point)) (point-at-eol)))
(d (+ off (max 0 (- c (current-column) 2))))
(tx (concat (buffer-substring (1- (point)) (point))
" "
(make-string d ? )
" "
(org-add-props (format "%s %3s %6s "
(make-string l ?*)
(if (zerop p) "" p)
(if (zerop h) "" (format "(%s h)" h)))
(list 'face 'fp-warn-face))
"")))
(if (not (featurep 'xemacs))
(overlay-put ov 'display tx)
(overlay-put ov 'invisible t)
(overlay-put ov 'end-glyph (make-glyph tx)))
(push ov fp-org-weight-overlays))))
(defun fp-org-weight-remove-overlays (&optional beg end noremove)
"Remove the occur highlights from the buffer.
BEG and END are ignored. If NOREMOVE is nil, remove this function
from the `before-change-functions' in the current buffer."
(interactive)
(unless org-inhibit-highlight-removal
(mapc 'delete-overlay fp-org-weight-overlays)
(setq fp-org-weight-overlays nil)
(unless noremove
(remove-hook 'before-change-functions
'fp-org-weight-remove-overlays 'local))))
;; Compliment of Nicolas Goaziou <n.goaziou@gmail.com>, 2012-02-26
(defun fp-org-weights-at-point ()
"Return cons of number of subtrees and paragraphs in the subtree at point.
Paragraphs (also encompasses equivalent structures)."
(org-with-wide-buffer
(org-narrow-to-subtree)
(let ((tree (org-element-parse-buffer 'element)) (num-hl 0) (num-el 0))
(org-element-map tree 'headline (lambda (hl) (incf num-hl)))
(org-element-map
tree '(paragraph table verse-block quote-block src-block example-block)
(lambda (el) (incf num-el)))
(cons (1- num-hl) num-el))))
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: viewing number of nested headlines
2013-02-05 10:39 ` Bastien
2013-02-05 12:43 ` François Pinard
@ 2013-02-05 13:25 ` Sebastien Vauban
2013-02-05 14:08 ` François Pinard
2013-02-05 20:17 ` 42 147
2 siblings, 1 reply; 10+ messages in thread
From: Sebastien Vauban @ 2013-02-05 13:25 UTC (permalink / raw
To: emacs-orgmode-mXXj517/zsQ
Bastien,
Bastien wrote:
> 42 147 <aeuster-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>> Is there a way to see how many nested headlines there are within a
>> higher-level headline (not necessarily top-level)?
>
> This is a nice feature of VimOrganizer but no, there is no way to do
> this with Org for now.
IIUC, this should (almost) answer the OP's request, by displaying the outline
path in mode line:
#+begin_src emacs-lisp
(add-hook 'org-mode-hook
(lambda() (add-to-list 'mode-line-format
'(:eval (org-propertize
(org-display-outline-path nil t " / " t)
'face 'mode-line-emphasis
'help-echo "Outline path")) t)))
#+end_src
A variation of it could directly count the number of levels...
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: viewing number of nested headlines
2013-02-05 13:25 ` Sebastien Vauban
@ 2013-02-05 14:08 ` François Pinard
0 siblings, 0 replies; 10+ messages in thread
From: François Pinard @ 2013-02-05 14:08 UTC (permalink / raw
To: emacs-orgmode
"Sebastien Vauban"
<wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
> IIUC, this should (almost) answer the OP's request, by displaying the outline
> path in mode line:
Oh, I completely missed the meaning of the OP request. Sorry for my noise.
François
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: viewing number of nested headlines
2013-02-05 12:43 ` François Pinard
@ 2013-02-05 18:34 ` Samuel Wales
0 siblings, 0 replies; 10+ messages in thread
From: Samuel Wales @ 2013-02-05 18:34 UTC (permalink / raw
To: François Pinard; +Cc: emacs-orgmode
Hi François,
This appears to implement a mechanism for putting overlays on
headlines. If so, this seems useful and would be a nice contrib or
core.
On 2/5/13, François Pinard <pinard@iro.umontreal.ca> wrote:
> I'm not sure the following code responds to your wish, maybe it would
> help enough? Surely, it is often useful to me. You might have to
> adapt the first few lines to your local installation or taste, however.
Samuel
--
The Kafka Pandemic: http://thekafkapandemic.blogspot.com
The disease DOES progress. MANY people have died from it. ANYBODY
can get it. There is no hope without action.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: viewing number of nested headlines
2013-02-05 10:39 ` Bastien
2013-02-05 12:43 ` François Pinard
2013-02-05 13:25 ` Sebastien Vauban
@ 2013-02-05 20:17 ` 42 147
2013-02-05 21:03 ` Bastien
2 siblings, 1 reply; 10+ messages in thread
From: 42 147 @ 2013-02-05 20:17 UTC (permalink / raw
To: Bastien; +Cc: Org Mode
[-- Attachment #1: Type: text/plain, Size: 741 bytes --]
Maybe you could point me in the right direction; somewhere in the code,
org-mode must be aware of the number of nested headlines in order for
show-branches and show-children to work. Or maybe it is not.
In any case, I'd try and adapt the code to display a number indicating (1)
position in the hierarchy; and (2) number of headlines at that / those
position(s).
Apologies if the original message was poorly articulated.
2013/2/5 Bastien <bzg@altern.org>
> 42 147 <aeuster@gmail.com> writes:
>
> > Is there a way to see how many nested headlines there are within a
> > higher-level headline (not necessarily top-level)?
>
> This is a nice feature of VimOrganizer but no, there is no way to do
> this with Org for now.
>
> --
> Bastien
>
[-- Attachment #2: Type: text/html, Size: 1175 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: viewing number of nested headlines
2013-02-05 20:17 ` 42 147
@ 2013-02-05 21:03 ` Bastien
2013-02-05 22:07 ` 42 147
0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2013-02-05 21:03 UTC (permalink / raw
To: 42 147; +Cc: Org Mode
Hi 42 (what's your other name?)
42 147 <aeuster@gmail.com> writes:
> Maybe you could point me in the right direction; somewhere in the
> code, org-mode must be aware of the number of nested headlines in
> order for show-branches and show-children to work. Or maybe it is
> not.
It is not. Long story short: folding a headline works by adding a
text overlay with the invisible property, and finding the end of the
overlay works by finding another headline of the same level. So there
is no nothing of "jumping" by N subtrees.
Still, you can fetch the number of invisible headline in a folded
subtree *afterwards* -- I assumed this is what François' code does.
> In any case, I'd try and adapt the code to display a number
> indicating (1) position in the hierarchy; and (2) number of
> headlines at that / those position(s).
This could end up in a minor mode or simply a feature that people
could turn on and off. But beware of the efficiency: with many
headlines, the folding features of Org combined with this feature
could become quite slow.
> Apologies if the original message was poorly articulated.
No problem, that's part of the game.
Thanks,
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: viewing number of nested headlines
2013-02-05 21:03 ` Bastien
@ 2013-02-05 22:07 ` 42 147
2013-02-06 20:50 ` Achim Gratz
0 siblings, 1 reply; 10+ messages in thread
From: 42 147 @ 2013-02-05 22:07 UTC (permalink / raw
To: Bastien; +Cc: Org Mode
[-- Attachment #1: Type: text/plain, Size: 1896 bytes --]
> Hi 42 (what's your other name?)
John is my real first name.
. . .
As for the rest, I didn't see some of the other replies, because the
org-mode mailing list moves a little two fast for my mailbox, and I prefer
to read selectively from the gmane archive.
That said, it is my responsibility to check that website before responding
to (some) of the messages that get forwarded to my e-mail address in a
thread I started.
Anyway, checking out some of the other solutions, since many were provided.
Thanks for the technical background on how headlines work in the code.
2013/2/5 Bastien <bzg@altern.org>
> Hi 42 (what's your other name?)
>
> 42 147 <aeuster@gmail.com> writes:
>
> > Maybe you could point me in the right direction; somewhere in the
> > code, org-mode must be aware of the number of nested headlines in
> > order for show-branches and show-children to work. Or maybe it is
> > not.
>
> It is not. Long story short: folding a headline works by adding a
> text overlay with the invisible property, and finding the end of the
> overlay works by finding another headline of the same level. So there
> is no nothing of "jumping" by N subtrees.
>
> Still, you can fetch the number of invisible headline in a folded
> subtree *afterwards* -- I assumed this is what François' code does.
>
> > In any case, I'd try and adapt the code to display a number
> > indicating (1) position in the hierarchy; and (2) number of
> > headlines at that / those position(s).
>
> This could end up in a minor mode or simply a feature that people
> could turn on and off. But beware of the efficiency: with many
> headlines, the folding features of Org combined with this feature
> could become quite slow.
>
> > Apologies if the original message was poorly articulated.
>
> No problem, that's part of the game.
>
> Thanks,
>
> --
> Bastien
>
[-- Attachment #2: Type: text/html, Size: 2473 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: viewing number of nested headlines
2013-02-05 22:07 ` 42 147
@ 2013-02-06 20:50 ` Achim Gratz
0 siblings, 0 replies; 10+ messages in thread
From: Achim Gratz @ 2013-02-06 20:50 UTC (permalink / raw
To: emacs-orgmode
42 147 writes:
> As for the rest, I didn't see some of the other replies, because the
> org-mode mailing list moves a little two fast for my mailbox, and I
> prefer to read selectively from the gmane archive.
>
> That said, it is my responsibility to check that website before
> responding to (some) of the messages that get forwarded to my e-mail
> address in a thread I started.
If you haven't done so already: On Gmane, switch to the "traditional"
interface, then call up any message in the thread and click on the
thread title: that will open just this thread and can be bookmarked
easily.
Better yet, use a real news reader (ahem, Gnus?) and connect to NNTP.
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-02-06 20:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-04 23:59 viewing number of nested headlines 42 147
2013-02-05 10:39 ` Bastien
2013-02-05 12:43 ` François Pinard
2013-02-05 18:34 ` Samuel Wales
2013-02-05 13:25 ` Sebastien Vauban
2013-02-05 14:08 ` François Pinard
2013-02-05 20:17 ` 42 147
2013-02-05 21:03 ` Bastien
2013-02-05 22:07 ` 42 147
2013-02-06 20:50 ` Achim Gratz
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.