buffers with major-mode as ~pdf-view-mode~ automatically switches to dark
mode when ~modus-themes-toggle~ is called.
- ** Toggle themes without reloading them
+ ** Decrease mode line height
+ :properties:
+ :custom_id: h:03be4438-dae1-4961-9596-60a307c070b5
+ :end:
+ #+cindex: Decrease mode line height
+
+ By default, the mode line of the Modus themes is set to 1 pixel width
+ for its =:box= attribute. In contrast, the mode line of stock Emacs is -1
+ pixel. This small difference is considered necessary for the purposes
+ of accessibility as our out-of-the-box design has a prominent color
+ around the mode line (a border) to make its boundaries clear. With a
+ negative width the border and the text on the mode line can feel a bit
+ more difficult to read under certain scenaria.
+
+ Furthermore, the user option ~modus-themes-mode-line~ ([[#h:27943af6-d950-42d0-bc23-106e43f50a24][Mode line]]) does not
+ allow for such a negative value because there are many edge cases that
+ simply make for a counter-intuitive set of possibilities, such as a =0=
+ value not being acceptable by the underlying face infrastructure, and
+ negative values greater than =-2= not being particularly usable.
+
+ For these reasons, users who wish to decrease the overall height of the
+ mode line must handle things on their own by implementing the methods
+ for face customization documented herein.
+
+ [[#h:1487c631-f4fe-490d-8d58-d72ffa3bd474][Basic face customization]].
+
+ One such method is to create a function that configures the desired
+ faces and hook it to ~modus-themes-after-load-theme-hook~ so that it
+ persists while switching between the Modus themes with the command
+ ~modus-themes-toggle~.
+
+ This one simply disables the box altogether, which will reduce the
+ height of the mode lines, but also remove their border:
+
+ #+begin_src emacs-lisp
+ (defun my-modus-themes-custom-faces ()
+ (set-face-attribute 'mode-line nil :box nil)
+ (set-face-attribute 'mode-line-inactive nil :box nil))
+
+ (add-hook 'modus-themes-after-load-theme-hook #'my-modus-themes-custom-faces)
+ #+end_src
+
+ The above relies on the ~set-face-attribute~ function, though users who
+ plan to reuse colors from the theme and do so at scale are better off
+ with the more streamlined combination of the ~modus-themes-with-colors~
+ macro and ~custom-set-faces~.
+
+ [[#h:51ba3547-b8c8-40d6-ba5a-4586477fd4ae][Face customization at scale]].
+
+ As explained before in this document, this approach has a syntax that is
+ consistent with the source code of the themes, so it probably is easier
+ to reuse parts of the design.
+
+ The following emulates the stock Emacs style, while still using the
+ colors of the Modus themes (whichever attribute is not explicitly stated
+ is inherited from the underlying theme):
+
+ #+begin_src emacs-lisp
+ (defun my-modus-themes-custom-faces ()
+ (modus-themes-with-colors
+ (custom-set-faces
+ `(mode-line ((,class :box (:line-width -1 :style released-button))))
+ `(mode-line-inactive ((,class :box (:line-width -1 :color ,bg-region)))))))
+
+ (add-hook 'modus-themes-after-load-theme-hook #'my-modus-themes-custom-faces)
+ #+end_src
+
+ And this one is like the out-of-the-box style of the Modus themes, but
+ with the -1 height instead of 1:
+
+ #+begin_src emacs-lisp
+ (defun my-modus-themes-custom-faces ()
+ (modus-themes-with-colors
+ (custom-set-faces
+ `(mode-line ((,class :box (:line-width -1 :color ,fg-alt))))
+ `(mode-line-inactive ((,class :box (:line-width -1 :color ,bg-region)))))))
+
+ (add-hook 'modus-themes-after-load-theme-hook #'my-modus-themes-custom-faces)
+ #+end_src
+
+ Finally, to also change the background color of the active mode line,
+ such as that it looks like the "accented" variant which is possible via
+ the user option ~modus-themes-mode-line~, the =:background= attribute needs
+ to be specified as well:
+
+ #+begin_src emacs-lisp
+ (defun my-modus-themes-custom-faces ()
+ (modus-themes-with-colors
+ (custom-set-faces
+ `(mode-line ((,class :box (:line-width -1 :color ,fg-alt) :background ,bg-active-accent)))
+ `(mode-line-inactive ((,class :box (:line-width -1 :color ,bg-region)))))))
+
+ (add-hook 'modus-themes-after-load-theme-hook #'my-modus-themes-custom-faces)
+ #+end_src
+
-** Toggle themes without reloading them
:properties:
:custom_id: h:b40aca50-a3b2-4c43-be58-2c26fcd14237
:end:
;; At this point, we're ready to resume undo recording for scratch.
(buffer-enable-undo "*scratch*")
-(defvar comp-subr-arities-h)
-(when (featurep 'native-compile)
- ;; Save the arity for all primitives so the compiler can always
- ;; retrieve it even in case of redefinition.
- (mapatoms (lambda (f)
- (when (subr-primitive-p (symbol-function f))
- (puthash f (func-arity f) comp-subr-arities-h))))
- ;; Fix the compilation unit filename to have it working when
- ;; installed or if the source directory got moved. This is set to be
- ;; a pair in the form of:
- ;; (rel-filename-from-install-bin . rel-filename-from-local-bin).
- (let ((bin-dest-dir (cadr (member "--bin-dest" command-line-args)))
- (eln-dest-dir (cadr (member "--eln-dest" command-line-args))))
- (when (and bin-dest-dir eln-dest-dir)
+(defvar load--bin-dest-dir nil
+ "Store the original value passed by \"--bin-dest\" during dump.
+Internal use only.")
+(defvar load--eln-dest-dir nil
+ "Store the original value passed by \"--eln-dest\" during dump.
+Internal use only.")
+
+(defun load--fixup-all-elns ()
+ "Fix all compilation unit filename.
+This to have it working when installed or if Emacs source
+directory got moved. This is set to be a pair in the form of:
+\(rel-filename-from-install-bin . rel-filename-from-local-bin)."
+ (when (and load--bin-dest-dir load--eln-dest-dir)
- (setq eln-dest-dir
+ (setq eln-dest-dir
- (concat eln-dest-dir "native-lisp/" comp-native-version-dir "/"))
+ (concat load--eln-dest-dir "native-lisp/" comp-native-version-dir "/"))
- (maphash (lambda (_ cu)
+ (maphash (lambda (_ cu)
+ (when (stringp (native-comp-unit-file cu))
(let* ((file (native-comp-unit-file cu))
(preloaded (equal (substring (file-name-directory file)
-10 -1)
(file-name-nondirectory
file)
eln-dest-dir-eff)
- bin-dest-dir)
+ load--bin-dest-dir)
;; Relative filename from the built uninstalled binary.
- (file-relative-name file invocation-directory)))))
- comp-loaded-comp-units-h)))
+ (file-relative-name file invocation-directory))))))
+ comp-loaded-comp-units-h)))
+
+(defvar comp-subr-arities-h)
+(when (featurep 'native-compile)
+ ;; Save the arity for all primitives so the compiler can always
- ;; retrive it even in case of redefinition.
++ ;; retrieve it even in case of redefinition.
+ (mapatoms (lambda (f)
+ (when (subr-primitive-p (symbol-function f))
+ (puthash f (func-arity f) comp-subr-arities-h))))
+ (setq load--bin-dest-dir (cadr (member "--bin-dest" command-line-args)))
+ (setq load--eln-dest-dir (cadr (member "--eln-dest" command-line-args)))
;; Set up the mechanism to allow inhibiting native-comp via
;; file-local variables.
(defvar comp--no-native-compile (make-hash-table :test #'equal)))
;; Internal utility functions
(defun sieve-manage--append-to-log (&rest args)
- "Append ARGS to `sieve-manage-log' buffer.
+ "Append ARGS to sieve-manage log buffer.
ARGS can be a string or a list of strings.
- The buffer to use for logging is specifified via
- `sieve-manage-log'. If it is nil, logging is disabled."
+ The buffer to use for logging is specified via `sieve-manage-log'.
-If it is nil, logging is disabled.
-
-When the `sieve-manage-log' buffer doesn't exist, it gets created (and
-configured with some initial settings)."
++If it is nil, logging is disabled."
(when sieve-manage-log
- (let* ((existing-log-buffer (get-buffer sieve-manage-log))
- (log-buffer (or existing-log-buffer
- (get-buffer-create sieve-manage-log))))
- (with-current-buffer log-buffer
- (unless existing-log-buffer
- ;; Do this only once, when creating the log buffer.
- (set-buffer-multibyte nil)
- (buffer-disable-undo))
- (goto-char (point-max))
- (apply #'insert args)))))
+ (with-current-buffer (or (get-buffer sieve-manage-log)
+ (with-current-buffer
+ (get-buffer-create sieve-manage-log)
+ (set-buffer-multibyte nil)
+ (buffer-disable-undo)))
+ (goto-char (point-max))
+ (apply #'insert args))))
(defun sieve-manage--message (format-string &rest args)
"Wrapper around `message' which also logs to sieve manage log.
)
\f
+(defun cperl-declaration-header-p (pos)
+ "Return t if POS is in the header of a declaration.
+Perl syntax can have various constructs between a
+keyword (e.g. \"sub\") and its associated block of code, and
+these can span several lines. These blocks are identified and
+marked with a text-property in `cperl-find-pods-heres'. This
+function tests that property."
+ (equal (get-text-property pos 'syntax-type) 'sub-decl))
+
(defun cperl-block-declaration-p ()
"Test whether the following ?\\{ opens a declaration block.
- Returns the column where the declarating keyword is found, or nil
+ Returns the column where the declaring keyword is found, or nil
if this isn't a declaration block. Declaration blocks are named
subroutines, packages and the like. They start with a keyword
and a name, to be followed by various descriptive items which are
(font-lock-ensure (point-min) (point-max))
(should (equal (get-text-property 4 'face) 'font-lock-variable-name-face))))
- ;;;; Re-use cperl-mode tests
+(ert-deftest perl-test-bug-34245 ()
+ "Test correct indentation after a hanging paren, with and without comments."
+ (with-temp-buffer
+ (perl-mode)
+ (insert "my @foo = (\n\"bar\",\n\"baz\",\n);")
+ (insert "\n\n")
+ (insert "my @ofoo = (\t\t# A comment.\n\"obar\",\n\"obaz\",\n);")
+ (indent-region (point-min) (point-max))
+ (goto-char (point-min))
+ (forward-line)
+ (skip-chars-forward " \t")
+ (should (equal (current-column) perl-indent-level))
+ (search-forward "# A comment.")
+ (forward-line)
+ (skip-chars-forward " \t")
+ (should (equal (current-column) perl-indent-level))))
+
+ ;;;; Reuse cperl-mode tests
(defvar cperl-test-mode)
(setq cperl-test-mode #'perl-mode)