help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing line and column number settings from some buffers


From: daniela-spit
Subject: Re: Removing line and column number settings from some buffers
Date: Sat, 5 Dec 2020 05:42:33 +0100

Have tried using your suggestion.  The file is being created
with the correct information.  However, when the code gets to
option 3, the Mode Line is not being reverted to its original
state.

Daniela


(defun change-mode-line (n)
   "Toggles Mode Line Information."

   (make-local-variable 'mode-line-position)
   (make-local-variable 'line-number-mode)
   (make-local-variable 'column-number-mode)
   (make-local-variable 'mode-line-modes)
   (make-local-variable 'mode-line-format)
   (make-local-variable 'original-mode-line-format)
   (make-local-variable 'mode-line-format)

   (cond
      ((= n 1)
       ;; Store current value of mode-line-format
         (setq original-mode-line-format mode-line-format)
         (data-to-file
            mode-line-format "~/.emacs.d/mode-line-frmt.el")

         (setq mode-line-position nil)
         (setq line-number-mode nil)
         (setq column-number-mode nil)
         (setq mode-line-modes nil)

         ;; Set format and discard System Load Averages indicator
         (setq display-time-format "W%W %H:%M")
         (make-local-variable 'display-time-default-load-average)
         (setq display-time-default-load-average nil)

         (display-time))

      ((= n 2)
         (setq display-time-format "W%W %H:%M %a %b %d %Y")
         (display-time))

      ((= n 3)
         ;; Put original mode-line-format
         (message "Doing 3")
         ;(setq mode-line-position t)
         ;(setq line-number-mode t)
         ;(setq column-number-mode t)
         ;(setq mode-line-modes t)

         ;(make-local-variable 'display-time-default-load-average)
         ;(setq display-time-default-load-average t)
         ;(display-time)

         (setq mode-line-format
            (data-from-file "~/.emacs.d/mode-line-frmt.el"))

      )))

(defun time-frmt-cycle ()
   (interactive)

   (unless (get 'time-frmt-cycle 'state)
      (put 'time-frmt-cycle 'state 1))

   (setq n (get 'time-frmt-cycle 'state))

   (when (= n 1)
      (change-mode-line 1)
      (put 'time-frmt-cycle 'state 2))
   (when (= n 2)
      (change-mode-line 2)
      (put 'time-frmt-cycle 'state 3))
   (when (= n 3)
      (message "3")
      (change-mode-line 3)
      (put 'time-frmt-cycle 'state 1)) )

(global-set-key (kbd "H-i H-i") #'time-frmt-cycle)

> Sent: Friday, December 04, 2020 at 8:19 AM
> From: "Jean Louis" <bugs@gnu.support>
> To: daniela-spit@gmx.it
> Cc: "Christopher Dimech" <dimech@gmx.com>, "Michael Heerdegen" 
> <michael_heerdegen@web.de>, help-gnu-emacs@gnu.org
> Subject: Re: Removing line and column number settings from some buffers
>
> (make-local-variable 'anything-here) will work, but toggle-mode-line
> is function and not variable
>
> * daniela-spit@gmx.it <daniela-spit@gmx.it> [2020-12-04 08:58]:
> > There is something wrong in resetting the mode line, after trying to save 
> > the
> > original value.  Michael has said that code only works if evaluated in a 
> > buffer.
> >
> > Would there be some other call to use?
> >
> > (defun toggle-mode-line (n)
> >    "Changes Mode Line Information."
> >
> >    (make-local-variable 'mode-line-position)
> >    (make-local-variable 'line-number-mode)
> >    (make-local-variable 'column-number-mode)
> >    (make-local-variable 'mode-line-modes)
> >    (make-local-variable 'mode-line-format)
> >    (make-local-variable 'original-mode-line-format)
> >    (make-local-variable 'mode-line-format)
> >
> >    (cond
> >       ((= n 1)
> >        ;; Store current value of mode-line-format
> >          (setq original-mode-line-format mode-line-format)
> >
> >          (setq mode-line-position nil)
> >          (setq line-number-mode nil)
> >          (setq column-number-mode nil)
> >          (setq mode-line-modes nil)
> >
> >          ;; Set format and discard System Load Averages indicator
> >          (setq display-time-format "W%W %H:%M")
> >          (make-local-variable 'display-time-default-load-average)
> >          (setq display-time-default-load-average nil)
> >
> >          (display-time))
> >
> >       ((= n 2)
> >          (setq display-time-format "W%W %H:%M %a %b %d %Y")
> >          (display-time))
> >
> >       ((= n 3)
> >          ;; Put original mode-line-format
> >          (setq mode-line-position t)
> >          (setq line-number-mode t)
> >          (setq column-number-mode t)
> >          (setq mode-line-modes t)
> >
> >          (setq mode-line-format original-mode-line-format)
> >          (force-mode-line-update)) ))
> >
> > (make-local-variable 'toggle-mode-line)
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]