Function: mixed-pitch-mode

mixed-pitch-mode is an interactive and natively compiled function defined in mixed-pitch.el.

Signature

(mixed-pitch-mode &optional ARG)

Documentation

Change the default face of the current buffer to a variable pitch, while keeping some faces fixed pitch.

See the variable mixed-pitch-fixed-pitch-faces for a list of which faces remain fixed pitch. The height and pitch of faces is inherited from variable-pitch and default.

This is a minor mode. If called interactively, toggle the Mixed-Pitch mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate the variable mixed-pitch-mode(var)/mixed-pitch-mode(fun).

The mode's hook is called both when the mode is enabled and when it is disabled.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/xaislv061pgqsfsqgax6yq3l1z5fal16-emacs-packages-deps/share/emacs/site-lisp/elpa/mixed-pitch-20210304.1900/mixed-pitch.el
;;;###autoload
(define-minor-mode mixed-pitch-mode
  "Change the default face of the current buffer to a variable pitch, while keeping some faces fixed pitch.

See the variable `mixed-pitch-fixed-pitch-faces' for a list of
which faces remain fixed pitch. The height and pitch of faces is
inherited from `variable-pitch' and `default'."
  :lighter " MPM"
  (let ((var-pitch (face-attribute mixed-pitch-face :family))
        (var-height (face-attribute mixed-pitch-face :height))
        (var-weight (face-attribute mixed-pitch-face :weight))
        (fix-pitch (face-attribute 'default :family))
        (fix-height (face-attribute 'default :height))
        (fix-weight (face-attribute 'default :weight)))
    ;; Turn mixed-pitch-mode on:
    (when (and (eq arg 'toggle)
               (not (eq mixed-pitch-face mixed-pitch--face))
               (not mixed-pitch-mode))
      ;; when toggling with a new face and mixed-pitch previously enabled
      (setq mixed-pitch-mode t))
    (if mixed-pitch-mode
        (progn
          (setq mixed-pitch--face mixed-pitch-face)
          ;; if already a remap applied, remove it first
          (when mixed-pitch--applied-p
            (face-remap-remove-relative mixed-pitch-variable-cookie)
            (dolist (cookie mixed-pitch-fixed-cookie)
              (face-remap-remove-relative cookie)))
          ;; remember cursor type
          (when mixed-pitch-variable-pitch-cursor
            (setq mixed-pitch-cursor-type cursor-type))
          ;; remap default face to variable pitch
          (setq mixed-pitch-variable-cookie
                (if mixed-pitch-set-height
                    (face-remap-add-relative
                     'default :family var-pitch :height var-height :weight var-weight)
                  (face-remap-add-relative 'default :family var-pitch :weight var-weight)))
          (setq mixed-pitch-fixed-cookie nil)
          ;; keep fonts in `mixed-pitch-fixed-pitch-faces' as fixed-pitch.
          (dolist (face mixed-pitch-fixed-pitch-faces)
            (add-to-list 'mixed-pitch-fixed-cookie
                         (if mixed-pitch-set-height
                             (face-remap-add-relative
                              face :family fix-pitch :height fix-height :weight fix-weight)
                           (face-remap-add-relative face :family fix-pitch :weight fix-weight))))
          ;; Change the cursor if the user requested:
          (when mixed-pitch-variable-pitch-cursor (setq cursor-type mixed-pitch-variable-pitch-cursor))
          (setq mixed-pitch--applied-p t))
      ;; Turn mixed-pitch-mode off:
      (progn (face-remap-remove-relative mixed-pitch-variable-cookie)
             (dolist (cookie mixed-pitch-fixed-cookie)
               (face-remap-remove-relative cookie))
             ;; Restore the cursor if we changed it:
             (when mixed-pitch-variable-pitch-cursor
               (setq cursor-type mixed-pitch-cursor-type))
             (setq mixed-pitch--applied-p nil)))))