memory-leaks

Still reachable: lots of words in many pages.
git clone https://git.kevinlegouguec.net/memory-leaks
Log | Files | Refs | README | LICENSE

form-feed.md (3606B)


      1 # Better out-of-the-box display for FORM FEED
      2 
      3 By default, FORM FEED is displayed as a dumb `^L` glyph.  This is
      4 surprising considering it shows up in so many places:
      5 
      6 - Emacs source files (C and Elisp),
      7 - help buffers:
      8     - `describe-mode`,
      9     - `describe-bindings`,
     10 - outline buffers:
     11     - several files under `etc/`
     12       - notably `NEWS`, as seen in `view-emacs-news`,
     13     - several files under `admin/`,
     14 - log buffers:
     15     - `*Compile-Log*`,
     16     - `*Dired log*`,
     17 - etc.
     18 
     19 You can even see it in source files of other GNU projects, like GCC.
     20 
     21 "Pages" are important enough to have their own navigation and
     22 narrowing commands, yet their default delimiter is displayed as an
     23 unassuming control character.
     24 
     25 I like the way form feeds are displayed with [`page-break-lines`];
     26 magit's `show-lines` blaming style achieves a similar look.
     27 
     28 Having this kind of display by default would make it more obvious that
     29 this character has actual navigation semantics; as it stands, it looks
     30 no different from some stray CARRIAGE RETURN (to the point where
     31 people unfamiliar with them [sometimes assume][junk] they are junk).
     32 
     33 This hypothetical thin-line display could be re-used by e.g.:
     34 
     35 - `apropos-documentation`, where symbol matches are delimited by
     36   strings of hyphens,
     37 
     38 - `describe-symbol`, where symbol definitions are delimited by text
     39   properties:
     40 
     41   ``` lisp
     42   (insert "\n\n"
     43           (eval-when-compile
     44             (propertize "\n" 'face '(:height 0.1 :inverse-video t)))
     45           "\n")
     46   ```
     47 
     48 - Custom buffers, where sections are delimited with a
     49   999-character-wide underlined space,
     50 
     51 - `eldoc-doc-buffer-separator`,
     52 
     53 - `shr-hr-line`
     54 
     55 See [emacs-devel][emacs-devel-thin-line] for a list of use-cases for
     56 thin lines, form-feed-related or not.
     57 
     58 [`page-break-lines`]: https://github.com/purcell/page-break-lines
     59 [junk]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41250#89
     60 [emacs-devel-thin-line]: https://lists.gnu.org/archive/html/emacs-devel/2019-05/msg00268.html
     61 
     62 ## State of the art
     63 
     64 Emacs has grown some facilities that we could build on:
     65 
     66 - `page-delimiter` locates spots in the buffer that mark page limits;
     67 - `(make-separator-line)` produces a "thin-line" representation.
     68 
     69 ## Incidental motivation
     70 
     71 This reflection started because moving over this underlined space with
     72 `truncate-lines` on caused the screen to jump horizontally.  This
     73 specific problem was fixed without dragging FORM FEED display into the
     74 discussion, but I feel like the latter is the more interesting issue
     75 ([who on Earth] enables `truncate-lines` by default anyway).
     76 
     77 Also `page-break-lines` breaks down in a couple of scenarios
     78 (e.g. form feeds embedded in diffs shown in Gnus or Magit; somehow
     79 vc-diff seems to fare better).  Those could probably be fixed, but it
     80 feels like effort would be better spent improving core, for the
     81 reasons given above.
     82 
     83 Also² `page-break-lines` causes Emacs ≥30 to hang with this recipe:
     84 
     85 ``` elisp
     86 ;;; -*- lexical-binding: t -*-
     87 
     88 (custom-set-variables
     89  '(global-page-break-lines-mode t nil (page-break-lines))
     90  '(inhibit-startup-screen t)
     91  '(window-restore-killed-buffer-windows nil))
     92 
     93 ;; Start Emacs; current buffer = *scratch*
     94 ;; C-x t 2      ; new tab
     95 ;; C-x k RET    ; kill *scratch*
     96 ;; C-TAB
     97 ```
     98 
     99 [who on Earth]: https://git.kevinlegouguec.net/dotfiles/tree/.emacs-custom.el
    100 
    101 ## Scratch pad
    102 
    103 In a temporary buffer:
    104 
    105 ```
    106 foobar
    107 ^L
    108 foobaz
    109 (put-text-property 8 10 'display (propertize "\n" 'face '(:height 0.1 :inverse-video t)))
    110 ```
    111 
    112 Possibly needs `:extend t` now?
    113 
    114 Grabbing the newline as well as the form-feed could be a way to ensure
    115 we do not fontify `^L`s embedded in strings?