[comp.emacs] Question on truncate-lines

markd@hpcupt1.HP.COM (Mark Diekhans) (10/04/89)

I would like to have a function to toggle the value of the truncate-lines
variable.  Unfortunatly doiung a setq or set-variable within a function
does not cause the window to be redrawn the was doing a M-x set-variable
command.  I am forced to use the following function, which redraws the
display after toggling the variable.  I don't want to wait for the entire
screen to be redrawn.  How do I force just the current window to be redrawn?

        (defun toggle-truncate-lines ()
          "Toggle the value of truncate-lines"
          (interactive)
          (setq truncate-lines (not truncate-lines))
          (redraw-display))

markd@hpsplrf.hp.com or hplabs!hpda!markd

kjones@talos.uucp (Kyle Jones) (10/05/89)

Mark Diekhans writes:
 > I would like to have a function to toggle the value of the truncate-lines
 > variable.  Unfortunatly doiung a setq or set-variable within a function
 > does not cause the window to be redrawn the was doing a M-x set-variable
 > command.  I am forced to use the following function, which redraws the
 > display after toggling the variable.  I don't want to wait for the entire
 > screen to be redrawn.  How do I force just the current window to be redrawn?
 > 
 >         (defun toggle-truncate-lines ()
 >           "Toggle the value of truncate-lines"
 >           (interactive)
 >           (setq truncate-lines (not truncate-lines))
 >           (redraw-display))

Change (redraw-display) to (scroll-up 0).  This is voodoo, very much
like the

  (set-buffer-modified-p (buffer-modified-p))
  (switch-to-buffer (other-buffer))

incantation used to trick Emacs into updating mode lines.

daveemme@uts.amdahl.com (Dave Emme) (10/05/89)

In article <-285219997@hpcupt1.HP.COM> markd@hpcupt1.HP.COM (Mark Diekhans) writes:
 >I would like to have a function to toggle the value of the truncate-lines
 >variable.  Unfortunatly doiung a setq or set-variable within a function
 >does not cause the window to be redrawn the was doing a M-x set-variable
 >command.  I am forced to use the following function, which redraws the
 >display after toggling the variable.  I don't want to wait for the entire
 >screen to be redrawn.  How do I force just the current window to be redrawn?
 >
 >        (defun toggle-truncate-lines ()
 >          "Toggle the value of truncate-lines"
 >          (interactive)
 >          (setq truncate-lines (not truncate-lines))
 >          (redraw-display))
 >
 >markd@hpsplrf.hp.com or hplabs!hpda!markd


Try this:

(defun toggle-truncate-lines()
  "Toggles the value of the variable truncate-lines for the current buffer."
  (interactive)
  (setq truncate-lines (not truncate-lines))
  (save-excursion
    (move-to-window-line 0)
    (recenter 0))
  (message "truncate-lines is now %s" truncate-lines))
-- 
------------------------------------------------------------------------------
Dave Emme                                     daveemme@uts.amdahl.com
Amdahl Corporation                  {ames, decwrl, sun, uunet}!amdahl!daveemme
1250 E. Arques Ave.   M/S 316
Sunnyvale, CA. 94088-3470

	 "Whenever you find yourself on the side of the majority,
	      it is time to pause and reflect." -- Mark Twain

rfortier@palladium.UUCP (Richard W. Fortier) (10/06/89)

In article <-285219997@hpcupt1.HP.COM> markd@hpcupt1.HP.COM (Mark Diekhans) writes:
>I would like to have a function to toggle the value of the truncate-lines
>variable.  

Why not simply:

	(set-variable 'truncate-lines (not truncate-lines))
-- 
---
Richard W. Fortier, Epoch Systems Inc. (508) 481-3717
313 Boston Post Rd. West, Marlboro MA 01752
{linus!alliant, harvard!cfisun}!palladium!rfortier