unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Javier <invalid@invalid.invalid>
To: help-gnu-emacs@gnu.org
Subject: Re: changing the display of formfeed characters
Date: Mon, 3 Sep 2018 17:23:30 +0000 (UTC)	[thread overview]
Message-ID: <pmjqmi$s18$1@gioia.aioe.org> (raw)
In-Reply-To: pmjek2$4ev$1@gioia.aioe.org

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	other threads:[~2018-09-03 17:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-31 11:22 changing the display of formfeed characters Javier
2018-09-01 13:51 ` Eli Zaretskii
2018-09-02 22:40   ` Drew Adams
2018-09-03 16:12     ` Eli Zaretskii
     [not found] ` <mailman.262.1535809931.1284.help-gnu-emacs@gnu.org>
2018-09-02 20:47   ` Javier
2018-09-03 16:14     ` Eli Zaretskii
2018-09-03  0:30 ` Nick Helm
     [not found] ` <mailman.318.1535934620.1284.help-gnu-emacs@gnu.org>
2018-09-03 13:57   ` Javier
2018-09-03 17:23     ` Javier [this message]
2018-09-04  6:43       ` Javier
2018-09-04  6:50         ` Javier
2018-09-07  0:26           ` Nick Helm
2018-09-07  3:56           ` Nick Helm

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='pmjqmi$s18$1@gioia.aioe.org' \
    --to=invalid@invalid.invalid \
    --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).