emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I'm not subscriber, but want to send a code.


From: Teika Kazura
Subject: I'm not subscriber, but want to send a code.
Date: Sun, 04 Feb 2024 08:59:14 +0900 (JST)

Hi, list moderators.

I'd like to submit a code to this mailing list without subscribing it.

Or, if you can forward the following to the list.

Thanks a lot for keeping this list.
------------------------------------------------------------------------
[Wishitem] Show the current node name in the header line (w/ sample 
implementation)
-----------------------------------------------------------------------
Hi. The following code shows the current "node name" (outline header
name) in the emacs header line:
------------------------------------------------------------------------
(defun org-mode-show-node-in-header ()
  (setq header-line-format
        '(:eval
          (org-compute-node-name-for-header))))

(defun org-compute-node-name-for-header ()
  (let ((level 0)
        cur
        (str "")
        (nodes (org-get-outline-path t)))
    (while nodes
      (unless (eq level 0)
        (setq str (concat str " ")))
      (setq cur (car nodes))
      (put-text-property 0 (length cur) 'face (nth level org-level-faces) cur)
      (setq str (concat str cur))
      (setq level (1+ level))
      (setq nodes (cdr nodes)))
    str
    ))

(add-hook 'org-mode-hook #'org-mode-show-node-in-header)
------------------------------------------------------------------------
If you like, adopt it for org-mode. Feel free to modify.

Several things have to be considered.

1. It does not seem there's a fixed word for "node name" (outline
headers). I know there's the function "org-get-outline-path". OTOH the
info does never use the word "path" for this purpose. Nor does
outline-mode (of Emacs.)

2. It's better to implement it as a minor mode.

3. In the header line, my code shows the node names concatenated by
" " (a single space), but it can be turned into an option. Some people
may prefer e.g. " > ".

4. I use org-level-faces. I think it's ok. If users don't like it,
they can hack the code.

5. Maybe you want to ask emacs upstream to enable multiple headers /
multiple-line header. (I'm sure then you'll throw yourself into a
tough situation.)

Sorry that I can't help with none of these issues.

I got an inspiration of this post from
https://emacs.stackexchange.com/a/30901 , but I wrote the code on my
own, so there is no copyright problem. Still you may want to check other
answers there to improve this.

Please cc: to me. I'm not subscribing the org mailing list.

I'm so grateful for your work in org-mode.

Best regards,
Teika



reply via email to

[Prev in Thread] Current Thread [Next in Thread]