emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Clarification on org-startup-fold behavior vs. docs
@ 2021-10-19 16:58 John Hendy
  2021-10-19 17:29 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: John Hendy @ 2021-10-19 16:58 UTC (permalink / raw)
  To: emacs-orgmode

Greetings,

I was surprised to open a file and find it in a fully expanded state.
I took a moment to try and figure out what one should do on a global
level. I searched "orgmode startup folded" and got here:
https://orgmode.org/manual/Initial-visibility.html

This points me to org-startup-folded, which has documentation here:
https://orgmode.org/manual/In_002dbuffer-Settings.html

#+begin_quote

The first set of options deals with the initial visibility of the
outline tree. The corresponding variable for global default settings
is org-startup-folded with a default value of showeverything.

‘overview’ Top-level headlines only.
‘content’ All headlines.
‘showall’ No folding on any entry.
‘show2levels’ Headline levels 1-2.
‘show3levels’ Headline levels 1-3.
‘show4levels’ Headline levels 1-4.
‘show5levels’ Headline levels 1-5.
‘showeverything’ Show even drawer contents.
#+end_quote

In addition, M-x customize-variable for org-startup-folded says:

#+begin_quote
org-startup-folded: "overview"
    State : CHANGED outside Customize. (mismatch)
   Non-nil means entering Org mode will switch to OVERVIEW. Hide

   This can also be configured on a per-file basis by adding one of
   the following lines anywhere in the buffer:

      #+STARTUP: fold              (or ‘overview’, this is equivalent)
      #+STARTUP: nofold            (or ‘showall’, this is equivalent)
      #+STARTUP: content
      #+STARTUP: showeverything
#+end_quote

Using the following min-config, I am unable to get a file to open in
folded state:

#+begin_example
(add-to-list 'load-path "~/.elisp/org/lisp/")
(add-to-list 'load-path "~/.elisp/org/contrib/lisp/")
(setq org-startup-folded "overview")
#+end_example

#+begin_example
* head1
asdf

* head2
asdf
#+end_example

With emacs -Q and M-x load-file path/to/min-config, it opens expanded
with either of these:
(setq org-startup-folded "fold")
(setq org-startup-folded "overview")

This does work:
(setq org-startup-folded t)

Is this the fact that I still don't really understand emacs inner
workings/elisp... or am I sane in feeling that the documentation and
behavior is not intuitive?

Interestingly this reddit thread poses the exact same question, yet
one user thinks this is completely expected? That said, he/she both
says "non-nil" and therefore `t` works... but not why "overview" or
"fold" are also not equivalent to "non-nil"?
https://www.reddit.com/r/emacs/comments/izf6xe


Thanks for taking a look,
John


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

* Re: Clarification on org-startup-fold behavior vs. docs
  2021-10-19 16:58 Clarification on org-startup-fold behavior vs. docs John Hendy
@ 2021-10-19 17:29 ` Ihor Radchenko
  2021-10-19 18:23   ` John Hendy
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2021-10-19 17:29 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

John Hendy <jw.hendy@gmail.com> writes:

> #+begin_example
> (add-to-list 'load-path "~/.elisp/org/lisp/")
> (add-to-list 'load-path "~/.elisp/org/contrib/lisp/")
> (setq org-startup-folded "overview")
> #+end_example

The value should be a symbol, not a string:

(setq org-startup-folded 'overview)

customise interface even tries to warn you that something is wrong:

> In addition, M-x customize-variable for org-startup-folded says:
>
> #+begin_quote
> org-startup-folded: "overview"
>     State : CHANGED outside Customize. (mismatch) <--- this is a clue 
>    Non-nil means entering Org mode will switch to OVERVIEW. Hide

If you select the value from customise interface, Emacs would set it
correctly.  Direct setting is indeed possible, but you need to consult
how the variable is defined.  Note the :type specifier below (also, see
15.4 Customization Types section of Elisp manual).

(defcustom org-startup-folded 'showeverything
  "Non-nil means entering Org mode will switch to OVERVIEW.

This can also be configured on a per-file basis by adding one of
the following lines anywhere in the buffer:

   #+STARTUP: fold              (or `overview', this is equivalent)
   #+STARTUP: nofold            (or `showall', this is equivalent)
   #+STARTUP: content
   #+STARTUP: show<n>levels (<n> = 2..5)
   #+STARTUP: showeverything

Set `org-agenda-inhibit-startup' to a non-nil value if you want
to ignore this option when Org opens agenda files for the first
time."
  :group 'org-startup
  :package-version '(Org . "9.4")
  :type '(choice
	  (const :tag "nofold: show all" nil)
	  (const :tag "fold: overview" t)
	  (const :tag "fold: show two levels" show2levels)
	  (const :tag "fold: show three levels" show3levels)
	  (const :tag "fold: show four levels" show4evels)
	  (const :tag "fold: show five levels" show5levels)
	  (const :tag "content: all headlines" content)
	  (const :tag "show everything, even drawers" showeverything)))

Best,
Ihor


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

* Re: Clarification on org-startup-fold behavior vs. docs
  2021-10-19 17:29 ` Ihor Radchenko
@ 2021-10-19 18:23   ` John Hendy
  0 siblings, 0 replies; 3+ messages in thread
From: John Hendy @ 2021-10-19 18:23 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

On Tue, Oct 19, 2021 at 12:28 PM Ihor Radchenko <yantar92@gmail.com> wrote:
>
> John Hendy <jw.hendy@gmail.com> writes:
> The value should be a symbol, not a string:
>
> (setq org-startup-folded 'overview)
>
> customise interface even tries to warn you that something is wrong:
>
> > In addition, M-x customize-variable for org-startup-folded says:
> >
> > #+begin_quote
> > org-startup-folded: "overview"
> >     State : CHANGED outside Customize. (mismatch) <--- this is a clue
> >    Non-nil means entering Org mode will switch to OVERVIEW. Hide

Thanks, this is helpful. I would, then, chalk this up to my ignorance
on emacs variables and such. This note also appeared when I was using
emacs -Q and it said I couldn't change it because I might have started
with -q, so I thought the "mismatch" might have just been some
artifact of that. I didn't know what "mismatch" meant and suspected it
might merely mean that I'd set this in a config, not with M-x
customize-variable.

> If you select the value from customise interface, Emacs would set it
> correctly.  Direct setting is indeed possible, but you need to consult
> how the variable is defined.  Note the :type specifier below (also, see
> 15.4 Customization Types section of Elisp manual).

This is a good reminder and I've done this before (see what it does to
my config custom variable section, then replicate directly). I didn't
think to do it this time.

My remaining question is why anything except nil (string or not) isn't
non-nil? Like I get that to set a specific setting, you'd need to
match a defined variable... but is it the case that non-parseable
types (expected var, got string) evaluates to nil?

I think the docs still throw me off. Note that showeverthing in the
lead up to the options is fontified as a variable (no backticks), but
below they are all backticked. I actually thought those were all
quoted, only realizing now they are [probably] backticks. I didn't
expect  both fixed width (which my brain reads as "code/variable")
*and* backticks on top.
https://orgmode.org/manual/In_002dbuffer-Settings.html

Actually, now I'm realizing these backticks go in the opposite slant
as what I'm used to? Or are they really single quotes, indeed?


Thanks again,
John
>
> Best,
> Ihor


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

end of thread, other threads:[~2021-10-19 18:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-19 16:58 Clarification on org-startup-fold behavior vs. docs John Hendy
2021-10-19 17:29 ` Ihor Radchenko
2021-10-19 18:23   ` John Hendy

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