emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] master 9ce1d38: Use curved quotes in core elisp diagno


From: Marcin Borkowski
Subject: Re: [Emacs-diffs] master 9ce1d38: Use curved quotes in core elisp diagnostics
Date: Fri, 21 Aug 2015 16:39:16 +0200

On 2015-08-21, at 15:58, Ricardo Wurmus <address@hidden> wrote:

> Dmitry Gutov <address@hidden> writes:
>
>> typopunc.el is authored by Oliver Scholz who seems to have copyright 
>> assignment signed, but the wiki page contains a lot of code snippets 
>> seemingly required to get the most out of the package.
>
> I’m using typopunct.el and all I needed was this:
>
>   (require 'typopunct)
>   (typopunct-change-language 'english t)
>
> It’s taking care of placing the typographically correct quotes and
> dashes—such as these—when I type ‘'’ or a series of dashes.
>
> When I don’t want this to happen I first hit ‘C-q’ before typing ‘'’,
> ‘"’, or ‘-’.  Modifying these characters depending on context is all
> typopunct does by default, and without any additional configuration.
>
> ~~ Ricardo

I'm also using typopunct, though I am not very happy with it.  The
advantage is that it is easy to add rules for another language, and to
switch languages on the fly:

--8<---------------cut here---------------start------------->8---
(require 'typopunct)
(add-to-list 'typopunct-language-alist
             `(polish ,(decode-char 'ucs #x201E) ; opening-double-q (outer)
                      ,(decode-char 'ucs #x201D) ; closing-double-q (outer)
                      )) ; closing-single-q (inner)
(setq-default typopunct-buffer-language 'polish)

(defun typopunct-toggle-language ()
  "Turn typopunct-mode on and toggle typopunct language between
`polish' and `english'."
  (interactive)
  (typopunct-mode 1)
  (message "Typopunct is on.  Language changed to %s."
           (if (string= typopunct-buffer-language "english")
               (typopunct-change-language "polish")
             (typopunct-change-language "english"))))

(defun typopunct-toggle-or-toggle-language (prefix)
  "Toggle typopunct on or off; with C-u, toggle the language."
  (interactive "P")
  (if prefix (typopunct-toggle-language)
    (typopunct-mode 'toggle)
    (message (format "Typopunct is %s.%s"
                     (if typopunct-mode "on" "off")
                     (if typopunct-mode
                         (concat "  Current language is " (symbol-name 
typopunct-buffer-language) ".")
                       "")))))

(global-set-key (kbd "C-z C-t") 'typopunct-toggle-or-toggle-language)
--8<---------------cut here---------------end--------------->8---

The disadvantage is that it probably should be a global minor mode.
This is especially important when editing the minibuffer.  While I'm in
a minibuffer, I can hit C-z C-t to switch it on, but this is cumbersome
(and doesn't work in Isearch).

Also, typopunct does its work with dashes based on the character before
point and not last-command or last-command-event or something like
that.  Not that it is a bad thing per se, but I'm not sure whether this
is the best solution.

So, typopunct as it is is definitely not sufficient; at least, it should
work in the minibuffer and with Isearch.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

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