emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* strange/cryptic org variables
@ 2020-01-23 19:16 D
  2020-01-25 16:41 ` Kyle Meyer
  2020-01-25 18:25 ` Bastien
  0 siblings, 2 replies; 3+ messages in thread
From: D @ 2020-01-23 19:16 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

org.el seems to define three weird variables: org-m, org-l and org-f
(see below).  Two of these variables (l and f) are used exclusively in
org-level-face, while m is not used anywhere in the code.  They don't
appear to be used in the other source files, either.

Is there a particular reason for them being accessible outside of the
function?  They seem oddly.. exposed.  Or is it some kind of performance
reason?

Here's the code in question, taken from Version 9.1.9, L6531 onward:

(defvar org-m nil)
(defvar org-l nil)
(defvar org-f nil)
(defun org-get-level-face (n)
  "Get the right face for match N in font-lock matching of headlines."
  (setq org-l (- (match-end 2) (match-beginning 1) 1))
  (when org-odd-levels-only (setq org-l (1+ (/ org-l 2))))
  (if org-cycle-level-faces
      (setq org-f (nth (% (1- org-l) org-n-level-faces) org-level-faces))
    (setq org-f (nth (1- (min org-l org-n-level-faces)) org-level-faces)))
  (cond
   ((eq n 1) (if org-hide-leading-stars 'org-hide org-f))
   ((eq n 2) org-f)
   (t (unless org-level-color-stars-only org-f))))

Cheers,
DW

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

* Re: strange/cryptic org variables
  2020-01-23 19:16 strange/cryptic org variables D
@ 2020-01-25 16:41 ` Kyle Meyer
  2020-01-25 18:25 ` Bastien
  1 sibling, 0 replies; 3+ messages in thread
From: Kyle Meyer @ 2020-01-25 16:41 UTC (permalink / raw)
  To: D, emacs-orgmode

D <d.williams@posteo.net> writes:

> org.el seems to define three weird variables: org-m, org-l and org-f
> (see below).  Two of these variables (l and f) are used exclusively in
> org-level-face, while m is not used anywhere in the code.  They don't
> appear to be used in the other source files, either.
>
> Is there a particular reason for them being accessible outside of the
> function?  They seem oddly.. exposed.  Or is it some kind of performance
> reason?

I doubt there's a convincing reason for these variables to exist.  They
have been around for a long time, as far back as you can trace the
history in the git repository: 4be4c5623 (version 4.12a, 2008-01-31).
Even in 4be4c5623, org-m wasn't used anywhere in the code base.

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

* Re: strange/cryptic org variables
  2020-01-23 19:16 strange/cryptic org variables D
  2020-01-25 16:41 ` Kyle Meyer
@ 2020-01-25 18:25 ` Bastien
  1 sibling, 0 replies; 3+ messages in thread
From: Bastien @ 2020-01-25 18:25 UTC (permalink / raw)
  To: D; +Cc: emacs-orgmode

Hi,

org-m was useful and the other two variables were not used outside of
`org-get-level-face', I put them in a let clause.

Thanks for pointing this issue!

-- 
 Bastien

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

end of thread, other threads:[~2020-01-25 18:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-23 19:16 strange/cryptic org variables D
2020-01-25 16:41 ` Kyle Meyer
2020-01-25 18:25 ` Bastien

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).