From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitrii Korobeinikov Subject: Re: Truncate lines option on file startup Date: Mon, 11 Nov 2019 15:58:34 +0600 Message-ID: References: <87k187gaof.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000063ce6505970f2d21" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:45015) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iU6T9-00054p-UH for emacs-orgmode@gnu.org; Mon, 11 Nov 2019 04:58:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iU6T8-00046H-LK for emacs-orgmode@gnu.org; Mon, 11 Nov 2019 04:58:47 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:41987) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iU6T8-00046A-Cc for emacs-orgmode@gnu.org; Mon, 11 Nov 2019 04:58:46 -0500 Received: by mail-wr1-x430.google.com with SMTP id a15so13852858wrf.9 for ; Mon, 11 Nov 2019 01:58:46 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "Fraga, Eric" Cc: emacs-orgmode --00000000000063ce6505970f2d21 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > 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. =D0=BF=D0=BD, 11 =D0=BD=D0=BE=D1=8F=D0=B1. 2019 =D0=B3. =D0=B2 14:40, Dmitr= ii Korobeinikov : > > # -*- 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: (#)"= ). > 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 STARTU= P > lines, so beware that it can also cause interference. > > Thanks all! > > =D0=B2=D1=81, 10 =D0=BD=D0=BE=D1=8F=D0=B1. 2019 =D0=B3. =D0=B2 18:47, Fra= ga, Eric : > >> 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 >> > --00000000000063ce6505970f2d21 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> 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
=C2=A0 (lambda ()=C2=A0
=C2=A0 =C2= =A0 (push (list "truncate" 'my/org-truncate-option 1) org-sta= rtup-options)
=C2=A0 =C2=A0 (push (list "notruncate" 'my/o= rg-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))))

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


=D0=BF=D0=BD, 11 =D0=BD=D0=BE=D1=8F=D0=B1. 2019 =D0= =B3. =D0=B2 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: (#<su= br set-buffer-redisplay>)"). Here is the code shall someone need it= :

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

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

Thanks all!

=D0=B2=D1=81, 10 =D0=BD= =D0=BE=D1=8F=D0=B1. 2019 =D0=B3. =D0=B2 18:47, Fraga, Eric <e.fraga@ucl.ac.uk>:
On Sunday, 10 Nov 201= 9 at 18:12, Dmitrii Korobeinikov wrote:
> PS if this turns out to be hairy, I can use .dir-locals.el, but the fe= ature
> 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
--00000000000063ce6505970f2d21--