bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18730: [PATCH] tildify.el: Add `auto-tildify' and `auto-tildify-mode


From: Michal Nazarewicz
Subject: bug#18730: [PATCH] tildify.el: Add `auto-tildify' and `auto-tildify-mode'.
Date: Thu, 23 Oct 2014 01:19:20 +0200
User-agent: Notmuch/0.17+15~gb65ca8e (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-unknown-linux-gnu)

On Fri, Oct 17 2014, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> So how would that work?  Would I have to also add setting of
>> tildify-string (or perhaps tildify-hard-space would be a better name)
>> variable in all major modes that tildify-string-alist now includes?
>
> Yes, that's how it should work.

So I came up with a patch whose excerpt is:

------ >8 --------------------------------------------------------------
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index bc10eab..446cdd4 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1206,6 +1206,8 @@ Entering SliTeX mode runs the hook `text-mode-hook', then 
the hook
 (defun tex-common-initialization ()
   ;; Regexp isearch should accept newline and formfeed as whitespace.
   (setq-local search-whitespace-regexp "[ \t\r\n\f]+")
+  ;; Use tilde as hard-space character in tildify package.
+  (setq-local hard-space-string "~")
   ;; A line containing just $$ is treated as a paragraph separator.
   (setq-local paragraph-start "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$")
   ;; A line starting with $$ starts a paragraph,
diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el
index 91f5a38..9f9e472 100644
--- a/lisp/textmodes/tildify.el
+++ b/lisp/textmodes/tildify.el
@@ -86,17 +86,29 @@ mode, the item for the mode SYMBOL is looked up in the 
alist instead."
                                        (integer :tag "Group "))
                                (symbol :tag "Like other")))))
 
+(defcustom hard-space-string nil
+  "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 \"&#160;\" 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 "No hard-space representation")
+                 (const  :tag "No-break space (U+00A0)" "\u00A0")
+                 (string :tag "Custom string"))
+  :safe t)
+
 (defcustom tildify-string-alist
------ >8 --------------------------------------------------------------

but now compilation fails with:

textmodes/tex-mode.el:1210:15:Warning: assignment to free variable
    `hard-space-string'

Requiring tildify in tex-mode (and other affected modes) seems a bit of
an overkill.  Am I doing something stupid here?  Or would moving the
local variable to another file?

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--





reply via email to

[Prev in Thread] Current Thread [Next in Thread]