Compare commits

...

2 Commits

Author SHA1 Message Date
Gerard Vermeulen
91930a038e Setup ielm' for better interoperability with smartparens' 2023-01-03 17:17:23 +01:00
Gerard Vermeulen
f41b701225 New method to let `engrave-faces' handle symbolic color names 2023-01-03 17:15:41 +01:00

View File

@ -675,6 +675,12 @@ and [[lst:3rd-window-management]] implement a selection of his recommendations.
#+name: lst:toggle-specific-advice
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
(defun toggle-engrave-faces-attribute-values-around ()
"Toggle `engrave-faces-attribute-values-around' advice."
(interactive)
(advice-toggle 'engrave-faces-attribute-values
:around #'engrave-faces-attribute-values-around))
(defun toggle-engrave-faces-latex-face-apply-override ()
"Toggle `engrave-faces-latex-face-apply' advice."
(interactive)
@ -912,6 +918,7 @@ defined in this Org file.
(define-short-documentation-group init
"Advice"
(advice-toggle :no-manual t)
(toggle-engrave-faces-attribute-values-around :no-manual t)
(toggle-engrave-faces-latex-face-apply-override :no-manual t)
(toggle-engrave-faces-latex-face-mapper-override :no-manual t)
(toggle-eww-display-pdf-around :no-manual t)
@ -2495,13 +2502,17 @@ this facility to a level acceptable for my workflow:
"faces")} have symbolic color names (beware: Emacs themes may replace the
symbolic color names with hexadecimal strings), this fix allows to engrave
for instance org-mode source blocks during LaTeX export without any
customization of =engrave-faces-themes=.
customization of =engrave-faces-themes=. Listing
[[lst:ensure-engrave-faces-with-attribute-values-fix]] proposes another method to
obtain the same result. Currently, I prefer to tangle listing
[[lst:ensure-engrave-faces-with-attribute-values-fix]] to the =user-init-file=
instead of listing [[lst:ensure-engrave-faces-with-latex-face-apply-fix]].
3. Listing [[lst:ensure-engrave-faces-with-latex-face-mapper-fix]] makes
=engrave-faces-latex-face-mapper= handle horizontal and vertical spacing
in multiple line documentation strings correctly. For instance, without this
fix the mishandling of vertical and horizontal spacing destroys the
indentation in Python documentation strings. An Emacs lisp example of the
bug is the disappearance of the empty line in the documentation string of
=engrave-faces-latex-face-mapper= handle horizontal and vertical spacing in
multiple line documentation strings correctly. For instance, without this fix
the mishandling of vertical and horizontal spacing destroys the indentation
in Python documentation strings. An Emacs lisp example of the bug is the
disappearance of the empty line in the documentation string of
=org-latex-engraved-source-block-filter= of listing
[[lst:org-latex-engraved-source-block-filter]] in exported =pdf= files. The idea
of the fix is to let the LaTeX face mapper wrap only groups of "words joined
@ -2591,10 +2602,10 @@ environments and non-floating breakable LaTeX environments by means of
[LISTINGS-SETUP]")))
#+end_src
#+caption[Fix engraving of symbolic color names]:
#+caption: Fix engraving of symbolic colors names.
#+caption[Fix engraving of symbolic color names in =engrave-faces-latex=]:
#+caption: Fix engraving of symbolic colors names in =engrave-faces-latex=.
#+name: lst:ensure-engrave-faces-with-latex-face-apply-fix
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(when (and (ensure-package-installation 'engrave-faces)
(require 'engrave-faces-latex nil t))
(defun engrave-faces-latex--color (color)
@ -2626,6 +2637,30 @@ environments and non-floating breakable LaTeX environments by means of
:override #'engrave-faces-latex-face-apply-override))
#+end_src
#+caption[Fix engraving of symbolic color names in =engrave-faces=]:
#+caption: Fix engraving of symbolic colors names in =engrave-faces=.
#+name: lst:ensure-engrave-faces-with-attribute-values-fix
#+begin_src emacs-lisp
(when (and (ensure-package-installation 'engrave-faces)
(require 'engrave-faces nil t))
(defun engrave-faces-attribute-values-around (efav-fun &rest args)
(let ((values (apply efav-fun args))
(attribute (cadr args)))
(if (not (member attribute '(:foreground :background)))
values
(mapcar (lambda (color)
(if (char-equal ?# (aref color 0))
color)
(apply 'format "#%02x%02x%02x"
(mapcar (lambda (c) (ash c -8))
(color-values color))))
values))))
(advice-add 'engrave-faces-attribute-values
:around #'engrave-faces-attribute-values-around))
#+end_src
#+caption[Fix engraving of horizontal/vertical spacing in multiline docstrings]:
#+caption: Fix engraving of horizontal and vertical spacing in multiple line
#+caption: documentation strings.
@ -4196,6 +4231,19 @@ Here is a list of links describing how to program and debug [[info:elisp#Top][Em
Ref. [cite:@Monnier.ACM-PL.4.1] exposes the evolution of Emacs Lisp and explains
many Emacs Lisp idioms.
Listing [[lst:setup-ielm][setup ielm]] customizes the [[https://wikemacs.org/wiki/IELM][Interactive Emacs Lisp Mode]] for better
interoperability with [[https://smartparens.readthedocs.io/en/latest/][Smartparens]]: get help on the key bindings by means of
src_emacs-lisp{(describe-mode (get-buffer "*ielm*"))}.
#+caption)}[Setup =ielm=]:
#+caption: Install =ielm=.
#+name: lst:setup-ielm
#+begin_src emacs-lisp
(with-eval-after-load 'ielm
(custom-set-variables
'(ielm-dynamic-return nil)))
#+end_src
** [[https://fennel-lang.org/][Fennel Programming]]
:PROPERTIES:
:CUSTOM_ID: sec:fennel-programming