From: Dmitry Gutov <dgutov@yandex.ru>
To: Paul Eggert <eggert@cs.ucla.edu>, emacs-devel@gnu.org
Subject: Re: A simple solution to "Upcoming loss of usability ..."
Date: Sun, 28 Jun 2015 04:04:04 +0300 [thread overview]
Message-ID: <558F4804.1020406@yandex.ru> (raw)
In-Reply-To: <558F10FA.409@cs.ucla.edu>
On 06/28/2015 12:09 AM, Paul Eggert wrote:
> How about if you pick a plausible option and give a realistic example
> showing (1) what the source code would be, (2) how the source code would
> be displayed, (3) what the *Help* buffer would be, (4) how the *Help*
> buffer would be displayed normally, and (5) how the *Help* buffer would
> be displayed if the user requests ASCII approximations.
Ok, try this, please. "\\" before a quote keeps it untranslated.
However, it order for us to be able to show an arbitrary number of
backslashes before a quote (both translated or not), the backslashes
also escape themselves. I've limited this effect to only before a quote,
so that we don't have to add them in a lot of places (like
substitute-command-keys docstring).
> I don't think any single example will illustrate all the gotchas. But
> how about if we start with the previously-mentioned example, e.g., type
> ‘C-h texinfo-format-verb’ after loading textmodes/texinfmt?
It's good to see how escaping works, but I meant an example of a Help
buffer where we must not translate quotes in the value.
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 4982ee5..aaaf02b 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -746,7 +746,8 @@ it is displayed along with the global value."
(setq from (point))
(pp origval)
(if (< (point) (+ from 20))
- (delete-region (1- from) from)))))))
+ (delete-region (1- from) from)))))
+ (put-text-property val-start-pos (point) 'help-value t)))
(terpri)
(when locus
(cond
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index f99e916..b5bf618 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -97,6 +97,18 @@ The format is (FUNCTION ARGS...).")
"Hook run by `help-mode'."
:type 'hook
:group 'help)
+
+(defcustom help-quote-translation nil
+ "Style to use for single quotes in help.
+The value is a left single quote character of some style.
+Quote ‘like this’ if the value is ?‘ (left single quotation mark).
+Quote \\'like this\\' if the value is ?\\' (apostrophe).
+Quote \\`like this\\' if the value is ?\\` (grave accent).
+The default value is nil, which means quote with left single quotation mark
+if displayable, and with grave accent otherwise."
+ :type 'character
+ :group 'help)
+
\f
;; Button types used by help
@@ -287,9 +299,37 @@ Commands:
\\{help-mode-map}"
(set (make-local-variable 'revert-buffer-function)
'help-mode-revert-buffer)
+ (setq font-lock-defaults '(nil t))
+ (font-lock-add-keywords
+ nil '(("\\(?:\\=\\|[^\\]\\)\\(\\\\*\\)[`']"
+ (0 (let* ((mbeg (match-beginning 1))
+ (mend (match-end 1))
+ (escapes (- mend mbeg)))
+ (unless (get-text-property mend 'help-value)
+ ;; Collapse all escaped backslashes.
+ (compose-region mbeg (+ mbeg (- escapes (/ escapes
2))) "")
+ ;; If there's an even number of backslashes,
+ ;; translate the quote.
+ (when (eq (logand escapes 1) 0)
+ (help--translate-quote mend)))
+ nil)))))
(set (make-local-variable 'bookmark-make-record-function)
'help-bookmark-make-record))
+(defun help--translate-quote (beg)
+ (let* ((char (char-after beg))
+ (replacement
+ (cond
+ ((or (and (null help-quote-translation)
+ (char-displayable-p ?‘))
+ (eq help-quote-translation ?‘))
+ (cdr (assq char '((?` . ?‘) (?' . ?’)))))
+ ((eq help-quote-translation ?')
+ ?')
+ (t char))))
+ (unless (eq char replacement)
+ (compose-region beg (1+ beg) replacement))))
+
;;;###autoload
(defun help-mode-setup ()
(help-mode)
diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el
index e7b6835..392d45b 100644
--- a/lisp/textmodes/texinfmt.el
+++ b/lisp/textmodes/texinfmt.el
@@ -2493,8 +2493,8 @@ surrounded by in angle brackets."
Enclose the verbatim text, including the delimiters, in braces. Print
text exactly as written (but not the delimiters) in a fixed-width.
-For example, @verb\{|@|\} results in @ and
-@verb\{+@'e?`!`+} results in @'e?`!`."
+For example, @verb{|@|} results in @ and
+@verb{+@\\'e?\\`!\\`+} results in @\\'e?\\`!\\`."
(let ((delimiter (buffer-substring-no-properties
(1+ texinfo-command-end) (+ 2 texinfo-command-end))))
next prev parent reply other threads:[~2015-06-28 1:04 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 14:59 A simple solution to "Upcoming loss of usability ..." Oleh Krehel
2015-06-25 15:37 ` Dmitry Gutov
2015-06-25 16:36 ` Paul Eggert
2015-06-25 17:00 ` Oleh Krehel
2015-06-25 20:48 ` Paul Eggert
2015-06-25 21:10 ` Dmitry Gutov
2015-06-25 22:15 ` Paul Eggert
2015-06-25 22:25 ` Dmitry Gutov
2015-06-25 22:41 ` Paul Eggert
2015-06-25 22:52 ` Dmitry Gutov
2015-06-27 15:00 ` raman
2015-06-25 18:32 ` Dmitry Gutov
2015-06-25 22:17 ` Paul Eggert
2015-06-25 22:38 ` Dmitry Gutov
2015-06-26 2:35 ` Paul Eggert
2015-06-26 12:06 ` Dmitry Gutov
2015-06-27 17:28 ` Paul Eggert
2015-06-27 17:53 ` Dmitry Gutov
2015-06-27 21:09 ` Paul Eggert
2015-06-28 1:04 ` Dmitry Gutov [this message]
2015-06-28 15:20 ` Paul Eggert
2015-06-28 20:27 ` Escaping quotes in docstrings, Was: " Dmitry Gutov
2015-06-28 23:29 ` Dmitry Gutov
2015-07-01 2:56 ` Paul Eggert
2015-07-02 0:09 ` Dmitry Gutov
2015-07-02 6:57 ` Paul Eggert
2015-07-02 9:46 ` Dmitry Gutov
2015-07-06 6:12 ` Paul Eggert
2015-07-06 12:07 ` Dmitry Gutov
2015-07-06 16:30 ` Paul Eggert
2015-07-06 22:10 ` Dmitry Gutov
2015-07-07 7:54 ` Paul Eggert
2015-07-07 8:39 ` Dmitry Gutov
2015-08-01 1:36 ` Paul Eggert
2015-08-01 21:05 ` Dmitry Gutov
2015-08-02 6:56 ` Paul Eggert
2015-08-02 12:51 ` Dmitry Gutov
2015-08-02 15:13 ` Paul Eggert
2015-08-02 18:31 ` Dmitry Gutov
2015-08-02 8:49 ` Przemysław Wojnowski
2015-08-02 19:16 ` Drew Adams
2015-06-27 17:57 ` Dmitry Gutov
2015-06-25 23:12 ` João Távora
2015-06-26 7:40 ` Oleh Krehel
2015-06-26 14:54 ` Paul Eggert
2015-06-26 15:03 ` Dmitry Gutov
2015-06-25 20:58 ` Alan Mackenzie
2015-06-25 22:34 ` Paul Eggert
2015-06-25 22:40 ` Dmitry Gutov
2015-06-25 22:45 ` Paul Eggert
2015-06-25 22:55 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=558F4804.1020406@yandex.ru \
--to=dgutov@yandex.ru \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).