unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: pietru@caramail.com
To: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Cycle that highlights whitespace and displays line-column numbers
Date: Fri, 29 Jan 2021 17:56:37 +0100	[thread overview]
Message-ID: <trinity-c398a2d0-977a-4e64-894e-4c5172c4223b-1611939397622@3c-app-mailcom-bs02> (raw)

I want to cycle through whitespace highlighting functionality, but I am
not getting very good behavior while looping.  I would be grateful if
people could help me improve the code.

(defvar-local dfvl-highlight-chars-state nil)

(defun cycle-highlight-chars ()
  "Cycle though character highlighting (tabs and trailing spaces)."
  (interactive)

  (when (eq dfvl-highlight-chars-state nil)
    (require 'whitespace)
    (setq whitespace-style '(face tab-mark tabs trailing)) )

  (pcase dfvl-highlight-chars-state
    (2 (whitespace-mode 0)                ; [#A] Disable emacs modes
       (display-line-numbers-mode 0)
       (setq line-number-mode nil)
       (setq column-number-mode nil)

       (ruler-mode 1)                     ; [#B] Enable emacs modes
       (message "%s" "Enable: Ruler only")
       (setq-local dfvl-highlight-chars-state 3))

    (3 (ruler-mode 0)                     ; [#C]
       (whitespace-mode 0)
       (setq line-number-mode nil)
       (setq column-number-mode nil)
       (display-line-numbers-mode 0)
       (message "%s" "Disable: Space highlight & frame measure")
       (setq-local dfvl-highlight-chars-state 1))

    (_ (whitespace-mode 1)                ; [#D]
       (ruler-mode 1)
       (setq line-number-mode 1)
       (setq column-number-mode 1)
       (display-line-numbers-mode 1)
       (message "%s" "Enable: Space highlight & frame measure")
       (setq-local dfvl-highlight-chars-state 2)) ))






             reply	other threads:[~2021-01-29 16:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-29 16:56 pietru [this message]
2021-01-29 19:59 ` Cycle that highlights whitespace and displays line-column numbers pietru

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=trinity-c398a2d0-977a-4e64-894e-4c5172c4223b-1611939397622@3c-app-mailcom-bs02 \
    --to=pietru@caramail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).