unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Dmitry Gutov <dgutov@yandex.ru>, emacs-devel@gnu.org
Subject: Re: Escaping quotes in docstrings, Was: A simple solution to "Upcoming loss of usability ..."
Date: Mon, 06 Jul 2015 09:30:31 -0700	[thread overview]
Message-ID: <559AAD27.3000403@cs.ucla.edu> (raw)
In-Reply-To: <559A6F86.2080809@yandex.ru>

Dmitry Gutov wrote:
> Why not put `escaped' (or rename that `translated', maybe) on those generated
> regions as well?

Yes, in theory it could be done.  But see below.

>> Second, and more generally, the overall approach seems error prone.  It
>> asks programmers to mark every quote character that should not be
>> transformed.  But characters can come from many different sources, and
>> it's hard to keep track of each place that can insert user data of some
>> sort.
>
> So far I've only seen a few places of complication nearby: key translations,
> keymap translations, and the escaping mechanism itself.

I'm afraid this is because you've only started looking.  Even if we limit 
ourselves to the regions you mention, the relevant code is scattered all over 
the place and it's hard to find exactly where to put 'escaped' or 'translated' 
into those regions.  For example, one place might be the following code in 
keymap.c's single_key_description function:

	  Lisp_Object result;
	  char *buffer = SAFE_ALLOCA (sizeof "<>"
				      + SBYTES (SYMBOL_NAME (key)));
	  esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key)));
	  result = build_string (buffer);
	  SAFE_FREE ();
	  return result;

Since KEY can be an arbitrary symbol, quite possibly its characters should be 
marked as 'escaped' or 'translated', which would mean adding this:

   put_text_property (1, 1 + SCHARS (SYMBOL_NAME (key)), Qescaped, Qt, result);

before the return.  Unfortunately it's not at all obvious whether this is needed 
unless one examines all the ways that C-h can put text into the *Help* buffer 
(which I haven't done).  And one must do this potentially every time a string or 
symbol name is looked at.  Plus, there are a lot of possibilities for off-by-one 
errors: for example, that '1 +' might easily be forgotten.  Plus, even then 
there are opportunities for bugs: the above call to 'put_text_property' is not 
correct if the symbol name contains a NUL byte.  Plus, there are other areas 
that will require this sort of complication, e.g., button labels, *Apropos* buffers.

In contrast, it's much easier to look through the code for ` inside a string, 
and mark the exceptional characters that are intended to be quotes and that are 
not automatically translated already.

> (we don't know all the possible sources the characters can
> come from? that's not very good).

No, actually, it's a good thing.  It's nice that programs can put arbitrary text 
into *Help* buffers, and that that we don't need to worry about where the text 
came from: it just works.  That's a simple interface, and simple interfaces are 
good.

> By the way, when doing translation in Lisp, instead of using help-mode-finish,
> we can instead examine all the functions that generate help buffers for Lisp
> stuff, and translate only the docstrings, when they are being inserted.

That's what the master branch is doing now, no?



  reply	other threads:[~2015-07-06 16:30 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
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 [this message]
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=559AAD27.3000403@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=dgutov@yandex.ru \
    --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).