emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Truncate lines option on file startup
@ 2019-11-10 12:12 Dmitrii Korobeinikov
  2019-11-10 12:47 ` Fraga, Eric
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitrii Korobeinikov @ 2019-11-10 12:12 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 522 bytes --]

Hi,

Thought it would be handy to be able to do this:

#+STARTUP: truncate
and
#+STARTUP: notruncate

Modifying org-startup-options manually wouldn't work as it describes how to
change a value of a variable or push onto a list, but no syntax for
function calls and for this to work toggle-truncate-lines is to be envoked.

I know about org-startup-truncated, but it's not file-by-file precision.

PS if this turns out to be hairy, I can use .dir-locals.el, but the feature
would still be a nice-to-have.

Regards,
Dmitrii

[-- Attachment #2: Type: text/html, Size: 730 bytes --]

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

* Re: Truncate lines option on file startup
  2019-11-10 12:12 Truncate lines option on file startup Dmitrii Korobeinikov
@ 2019-11-10 12:47 ` Fraga, Eric
  2019-11-11  8:40   ` Dmitrii Korobeinikov
  0 siblings, 1 reply; 4+ messages in thread
From: Fraga, Eric @ 2019-11-10 12:47 UTC (permalink / raw)
  To: Dmitrii Korobeinikov; +Cc: emacs-orgmode

On Sunday, 10 Nov 2019 at 18:12, Dmitrii Korobeinikov wrote:
> PS if this turns out to be hairy, I can use .dir-locals.el, but the feature
> would still be a nice-to-have.

You could use file local variables for this, e.g.

# Local Variables:
# truncate-lines: t
# End:

at the end of your org file or

# -*- truncate-lines: t; -*-

as the first line of your file.

This is not org specific so I guess there is no real justification for
an org variable for this feature.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.2.6-552-g8c5a78

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

* Re: Truncate lines option on file startup
  2019-11-10 12:47 ` Fraga, Eric
@ 2019-11-11  8:40   ` Dmitrii Korobeinikov
  2019-11-11  9:58     ` Dmitrii Korobeinikov
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitrii Korobeinikov @ 2019-11-11  8:40 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1470 bytes --]

> # -*- truncate-lines: t; -*-

This works nicely, thank you! Never knew about these.

By the way, I got the STARTUP to function. Turns out it's enough to set
truncate-lines variable and the change is picked up automatically (docs
say: "Calls these functions when changed: (#<subr set-buffer-redisplay>)").
Here is the code shall someone need it:

(eval-after-load 'org
  (lambda ()
    (setq org-startup-truncated nil)
    (push (list "truncate" 'truncate-lines t) org-startup-options)
    (push (list "notruncate" 'truncate-lines nil) org-startup-options)))

Note that (setq org-startup-truncated nil) is needed for the notruncate
option to work. Plus the stuff in the org-mode-hook runs after the STARTUP
lines, so beware that it can also cause interference.

Thanks all!

вс, 10 нояб. 2019 г. в 18:47, Fraga, Eric <e.fraga@ucl.ac.uk>:

> On Sunday, 10 Nov 2019 at 18:12, Dmitrii Korobeinikov wrote:
> > PS if this turns out to be hairy, I can use .dir-locals.el, but the
> feature
> > would still be a nice-to-have.
>
> You could use file local variables for this, e.g.
>
> # Local Variables:
> # truncate-lines: t
> # End:
>
> at the end of your org file or
>
> # -*- truncate-lines: t; -*-
>
> as the first line of your file.
>
> This is not org specific so I guess there is no real justification for
> an org variable for this feature.
>
> --
> Eric S Fraga via Emacs 27.0.50, Org release_9.2.6-552-g8c5a78
>

[-- Attachment #2: Type: text/html, Size: 1981 bytes --]

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

* Re: Truncate lines option on file startup
  2019-11-11  8:40   ` Dmitrii Korobeinikov
@ 2019-11-11  9:58     ` Dmitrii Korobeinikov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitrii Korobeinikov @ 2019-11-11  9:58 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2306 bytes --]

> beware that it can also cause interference.
> Here is the code shall someone need it:

And just not to leave the bad code be, here is a different, better way:

(setq my/org-truncate-option nil)
(eval-after-load 'org
  (lambda ()
    (push (list "truncate" 'my/org-truncate-option 1) org-startup-options)
    (push (list "notruncate" 'my/org-truncate-option -1)
org-startup-options)))
And in org-mode hook:
(lambda () (case my/org-truncate-option (1 (setq truncate-lines t)) (-1
(setq truncate-lines nil))))

this avoids interference w/ org-startup-truncated while giving flexibility
to conditionally set truncation in .dir-locals.el and STARTUP will always
work.


пн, 11 нояб. 2019 г. в 14:40, Dmitrii Korobeinikov <dim1212k@gmail.com>:

> > # -*- truncate-lines: t; -*-
>
> This works nicely, thank you! Never knew about these.
>
> By the way, I got the STARTUP to function. Turns out it's enough to set
> truncate-lines variable and the change is picked up automatically (docs
> say: "Calls these functions when changed: (#<subr set-buffer-redisplay>)").
> Here is the code shall someone need it:
>
> (eval-after-load 'org
>   (lambda ()
>     (setq org-startup-truncated nil)
>     (push (list "truncate" 'truncate-lines t) org-startup-options)
>     (push (list "notruncate" 'truncate-lines nil) org-startup-options)))
>
> Note that (setq org-startup-truncated nil) is needed for the notruncate
> option to work. Plus the stuff in the org-mode-hook runs after the STARTUP
> lines, so beware that it can also cause interference.
>
> Thanks all!
>
> вс, 10 нояб. 2019 г. в 18:47, Fraga, Eric <e.fraga@ucl.ac.uk>:
>
>> On Sunday, 10 Nov 2019 at 18:12, Dmitrii Korobeinikov wrote:
>> > PS if this turns out to be hairy, I can use .dir-locals.el, but the
>> feature
>> > would still be a nice-to-have.
>>
>> You could use file local variables for this, e.g.
>>
>> # Local Variables:
>> # truncate-lines: t
>> # End:
>>
>> at the end of your org file or
>>
>> # -*- truncate-lines: t; -*-
>>
>> as the first line of your file.
>>
>> This is not org specific so I guess there is no real justification for
>> an org variable for this feature.
>>
>> --
>> Eric S Fraga via Emacs 27.0.50, Org release_9.2.6-552-g8c5a78
>>
>

[-- Attachment #2: Type: text/html, Size: 3222 bytes --]

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

end of thread, other threads:[~2019-11-11  9:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-10 12:12 Truncate lines option on file startup Dmitrii Korobeinikov
2019-11-10 12:47 ` Fraga, Eric
2019-11-11  8:40   ` Dmitrii Korobeinikov
2019-11-11  9:58     ` Dmitrii Korobeinikov

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