Variable: mixed-pitch-mode

mixed-pitch-mode is a buffer-local variable defined in mixed-pitch.el.

Documentation

Non-nil if Mixed-Pitch mode is enabled.

Use the command mixed-pitch-mode(var)/mixed-pitch-mode(fun) to change this variable.

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)))))