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

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

Re: changing the display of formfeed characters


From: Javier
Subject: Re: changing the display of formfeed characters
Date: Mon, 3 Sep 2018 17:23:30 +0000 (UTC)
User-agent: tin/2.2.1-20140504 ("Tober an Righ") (UNIX) (Linux/3.18.6-1-ARCH (x86_64))

I have solved it now.  It only lacks hooks to adjust to the window
width in real time.

Taking the code of whitespace-newline-mode from whitespace.el,
s/newline/formfeed/, adding whitespace-display-mappings in the
let varlist et voilá! a minor mode that displays formfeed and
coexists well with whitespace-mode.

Thanks to Nick Helm for guiding me in the right direction.


(setq formfeed-display-string-length 70)
(setq formfeed-display-string (make-vector formfeed-display-string-length ?-))

(setq whitespace-display-mappings
      ;;fancy chars from http://ergoemacs.org/emacs/modernization_formfeed.html
      ;; all numbers are unicode     codepoint in decimal. e.g. (insert-char 
182 1)
      `((space-mark 32 [183]  [46]) ; SPACE 32 「 」, 183 MIDDLE DOT 「·」, 46 FULL 
STOP 「.」
        (space-mark 160 [164] [95])
        (newline-mark 10 [182 10]) ; LINE FEED,
        (tab-mark 9 [9655 9] [92 9]) ; TAB
        (newline-mark ?\^L  ,formfeed-display-string))  ; FORM FEED
                                                  )

(define-minor-mode global-whitespace-formfeed-mode
  "Toggle global formfeed visualization (Global Whitespace Formfeed mode).
With a prefix argument ARG, enable Global Whitespace Formfeed mode
if ARG is positive, and disable it otherwise.

If called from Lisp, also enables the mode if ARG is omitted or nil,
and toggles it if ARG is `toggle'.

Use `global-whitespace-formfeed-mode' only for FORMFEED
visualization exclusively.  For other visualizations, including
FORMFEED visualization together with (HARD) SPACEs and/or TABs,
please use `global-whitespace-mode'."
  :lighter    " NL"
  :init-value nil
  :global     t
  :group      'whitespace

  (let ((whitespace-style '(face newline-mark newline))
        (whitespace-display-mappings  `( (newline-mark ?\^L 
,formfeed-display-string)  )))
    (global-whitespace-mode (if global-whitespace-formfeed-mode
                                1 -1))
    ;; sync states (running a batch job)
    (setq global-whitespace-formfeed-mode global-whitespace-mode)))

(define-minor-mode whitespace-formfeed-mode
  "Toggle formfeed visualization (Whitespace Formfeed mode).
With a prefix argument ARG, enable Whitespace Formfeed mode if ARG
is positive, and disable it otherwise.

If called from Lisp, also enables the mode if ARG is omitted or nil,
and toggles it if ARG is `toggle'.

Use `whitespace-formfeed-mode' only for FORMFEED visualization
exclusively.  For other visualizations, including FORMFEED
visualization together with (HARD) SPACEs and/or TABs, please,
use `whitespace-mode'."
  :lighter    " nl"
  :init-value nil
  :global     nil
  :group      'whitespace
  (let ((whitespace-style '(face newline-mark newline))
        (whitespace-display-mappings  `( (newline-mark ?\^L 
,formfeed-display-string)  )))
    (whitespace-mode (if whitespace-formfeed-mode
                         1 -1)))
  ;; sync states (running a batch job)
  (setq whitespace-formfeed-mode whitespace-mode))


reply via email to

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