Function: tildify-mode

tildify-mode is an autoloaded, interactive and byte-compiled function defined in tildify.el.gz.

Signature

(tildify-mode &optional ARG)

Documentation

Adds electric behavior to space character.

When space is inserted into a buffer in a position where hard space is required instead (determined by tildify-space-pattern and tildify-space-predicates), that space character is replaced by a hard space specified by tildify-space-string. Converting of the space is done by tildify-space.

When tildify-mode(var)/tildify-mode(fun) is enabled, if tildify-string-alist specifies a hard space representation for current major mode, the tildify-space-string buffer-local variable will be set to the representation.

This is a minor mode. If called interactively, toggle the Tildify 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 tildify-mode(var)/tildify-mode(fun).

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

Probably introduced at or before Emacs version 25.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/tildify.el.gz
;;;###autoload
(define-minor-mode tildify-mode
  "Adds electric behavior to space character.

When space is inserted into a buffer in a position where hard space is required
instead (determined by `tildify-space-pattern' and `tildify-space-predicates'),
that space character is replaced by a hard space specified by
`tildify-space-string'.  Converting of the space is done by `tildify-space'.

When `tildify-mode' is enabled, if `tildify-string-alist' specifies a hard space
representation for current major mode, the `tildify-space-string' buffer-local
variable will be set to the representation."
  :lighter " ~"
  (when tildify-mode
    (let ((space (with-suppressed-warnings ((obsolete
                                             tildify--pick-alist-entry))
                   (tildify--pick-alist-entry tildify-string-alist))))
      (if (not (string-equal " " (or space tildify-space-string)))
          (when space
            (setq tildify-space-string space))
        (message (concat "Hard space is a single space character, tildify-"
                         "mode won't have any effect, disabling."))
        (setq tildify-mode nil))))
  (if tildify-mode
      (add-hook 'post-self-insert-hook #'tildify-space nil t)
    (remove-hook 'post-self-insert-hook #'tildify-space t)))