diff options
author | Michal Nazarewicz <mina86@mina86.com> | 2014-11-16 17:38:15 +0100 |
---|---|---|
committer | Michal Nazarewicz <mina86@mina86.com> | 2014-11-18 00:46:50 +0100 |
commit | b8104090075eb28dd6680cc9f8b0a49674ca369a (patch) | |
tree | 6a4cb090a7ac881eb370edc8ac53938f3d291329 /lisp/textmodes/tildify.el | |
parent | 07556b0299b33b52cf352581bfdd6554819eea30 (diff) | |
download | emacs-b8104090075eb28dd6680cc9f8b0a49674ca369a.tar.gz |
tildify.el: introduce a `tildify-space-string' variable
* textmodes/tildify.el (tildify-space-string): New variable for
specifying representation of a hard space -- a no-break space by
default. Being a buffer-local variable it is much easier to
handle than `tildify-string-alist' that has been used so far. It
also works better with derived modes.
(tildify-string-alist): Mark as obsolete.
* textmodes/tex-mode.el (tex-common-initialization): Set
`tildify-space-string' variable in all variants of TeX mode since
`tildify-string-alist' is now empty by default.
* nxml/nxml-mode.el (nxml-mode): Ditto in `nxml-mode'. If
encoding supports it use no-break space instead of character
entity; this changes previous default which used a numeric
reference.
* textmodes/sgml-mode.el (sgml-mode): ditto in `sgml-mode'. If
encoding does not support no-break space, use numeric reference;
this changes previous default which used named entity (“ ”)
in HTML mode.
Diffstat (limited to 'lisp/textmodes/tildify.el')
-rw-r--r-- | lisp/textmodes/tildify.el | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index 91f5a38ce0b..865dcecbecc 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -4,7 +4,7 @@ ;; Author: Milan Zamazal <pdm@zamazal.org> ;; Michal Nazarewicz <mina86@mina86.com> -;; Version: 4.5.4 +;; Version: 4.5.5 ;; Keywords: text, TeX, SGML, wp ;; This file is part of GNU Emacs. @@ -86,15 +86,24 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." (integer :tag "Group ")) (symbol :tag "Like other"))))) -(defcustom tildify-string-alist - '((latex-mode . "~") - (tex-mode . latex-mode) - (plain-tex-mode . latex-mode) - (sgml-mode . " ") - (html-mode . sgml-mode) - (xml-mode . " ") ; XML does not define use numeric reference - (nxml-mode . xml-mode) - (t . " ")) +(defcustom tildify-space-string "\u00A0" + "Representation of a hard (a.k.a. no-break) space in current major mode. + +Used by `tildify-buffer' in places where space is required but line +cannot be broken. For example \"~\" for TeX or \" \" for SGML, +HTML and XML modes. A no-break space Unicode character (\"\\u00A0\") +might be used for other modes if compatible encoding is used. + +If nil, current major mode has no way to represent a hard space." + :version "25.1" + :group 'tildify + :type '(choice (const :tag "Space character (no hard-space representation)" + " ") + (const :tag "No-break space (U+00A0)" "\u00A0") + (string :tag "Custom string")) + :safe t) + +(defcustom tildify-string-alist () "Alist specifying what is a hard space in the current major mode. Each alist item is of the form (MAJOR-MODE . STRING) or @@ -118,6 +127,8 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." (choice (const :tag "No-break space (U+00A0)" "\u00A0") (string :tag "String ") (symbol :tag "Like other"))))) +(make-obsolete-variable 'tildify-string-alist + 'tildify-space-string "25.1") (defcustom tildify-ignored-environments-alist `((latex-mode @@ -193,7 +204,7 @@ END-REGEX defines end of the corresponding text part and can be either: ;;;###autoload (defun tildify-region (beg end &optional dont-ask) "Add hard spaces in the region between BEG and END. -See variables `tildify-pattern-alist', `tildify-string-alist', and +See variables `tildify-pattern-alist', `tildify-space-string', and `tildify-ignored-environments-alist' for information about configuration parameters. This function performs no refilling of the changed text. @@ -214,7 +225,7 @@ won't be prompted for confirmation of each substitution." ;;;###autoload (defun tildify-buffer (&optional dont-ask) "Add hard spaces in the current buffer. -See variables `tildify-pattern-alist', `tildify-string-alist', and +See variables `tildify-pattern-alist', `tildify-space-string', and `tildify-ignored-environments-alist' for information about configuration parameters. This function performs no refilling of the changed text. @@ -303,7 +314,8 @@ replacements done and response is one of symbols: t (all right), nil (let* ((alist (tildify--pick-alist-entry tildify-pattern-alist)) (regexp (car alist)) (match-number (cadr alist)) - (tilde (tildify--pick-alist-entry tildify-string-alist)) + (tilde (or (tildify--pick-alist-entry tildify-string-alist) + tildify-space-string)) (end-marker (copy-marker end)) answer bad-answer |