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

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

Re: display line and column numbers together with ruler and whitespace h


From: michael-franzese
Subject: Re: display line and column numbers together with ruler and whitespace highlighting
Date: Sun, 31 Jan 2021 01:24:11 +0100

I have re-coded my function cycle-posn-cursor-spaces

The funny thing is that calling posn-cursor-spaces does not enable
ruler-mode, yet  (setq line-number-mode t) and (setq column-number-mode t)
are executed correctly.

(require 'whitespace)
(setq whitespace-style '(face tab-mark tabs trailing))
(defvar dfv-posn-cursor-spaces-state nil)

(defun cycle-posn-cursor-spaces ()
  "Cycle though character highlighting (tabs and trailing spaces)."
  (interactive)
  ;;
  (pcase dfv-posn-cursor-spaces-state
    ;;
    (1 (ruler-mode 1)
       (setq line-number-mode t)
       (setq column-number-mode t)
       (whitespace-mode 1)
       (message "%s" "Enable: Show position of cursor and spaces")
       (setq dfv-posn-cursor-spaces-state 2))
    ;;
    (2 (setq line-number-mode nil)
       (setq column-number-mode nil)
       (whitespace-mode 0)
       (message "%s" "Enable: Show position of cursor")
       (setq dfv-posn-cursor-spaces-state 0))
    ;;
    (_ (ruler-mode 0)
       (setq line-number-mode nil)
       (setq column-number-mode nil)
       (whitespace-mode 0)
       (message "%s" "Disable: Show position of cursor and spaces")
       (setq dfv-posn-cursor-spaces-state 1)) ))

(defun posn-cursor-spaces ()
  "Shows position of cursor and spaces."
  (interactive)
  (setq dfv-posn-cursor-spaces-state 1)
  (cycle-posn-cursor-spaces))






> Sent: Sunday, January 31, 2021 at 9:15 AM
> From: michael-franzese@gmx.com
> To: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: display line and column numbers together with ruler and whitespace 
> highlighting
>
> I have a problem on the correct way to display line and column numbers
> together with a ruler and whitespace highlighting, with the ability to
> cycle through the different options.
>
>
> (defvar dfv-highlight-spaces-state nil)
>
> (defun cycle-highlight-spaces ()
>   "Cycle though character highlighting (tabs and trailing spaces)."
>   (interactive)
>
>   (pcase dfv-highlight-spaces-state
>     (2 (display-line-numbers-mode 0)
>        (setq line-number-mode nil)
>        (setq column-number-mode nil)
>        (ruler-mode 1)
>        (whitespace-mode 0)
>        (message "%s" "Enable: Ruler only")
>        (setq dfv-highlight-spaces-state 3))
>
>     (3 (ruler-mode 0)
>        (setq line-number-mode nil)
>        (setq column-number-mode nil)
>        (display-line-numbers-mode 0)
>        (whitespace-mode 0)
>        (message "%s" "Disable: Show spaces & cursor position")
>        (setq dfv-highlight-spaces-state 1))
>
>     (_ (ruler-mode 1)
>        (setq line-number-mode t)
>        (setq column-number-mode t)
>        (display-line-numbers-mode 1)
>        (whitespace-mode 1)
>        (message "%s" "Enable: Show spaces & cursor position")
>        (setq dfv-highlight-spaces-state 2)) ))
>
>
>
>
>
>



reply via email to

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