]> code.delx.au - gnu-emacs/blobdiff - src/doc.c
* test/lisp/help-fns-tests.el: Add several tests for 'describe-function'.
[gnu-emacs] / src / doc.c
index 7cdb0d03a81ca9cf7cb82ae821c9c6686a212c14..6ffdad10f030221f1ee54943bce482f04de4bcc0 100644 (file)
--- a/src/doc.c
+++ b/src/doc.c
@@ -339,16 +339,7 @@ string is passed through `substitute-command-keys'.  */)
   if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
     fun = XCDR (fun);
   if (SUBRP (fun))
-    {
-      if (XSUBR (fun)->doc == 0)
-       return Qnil;
-      /* FIXME: This is not portable, as it assumes that string
-        pointers have the top bit clear.  */
-      else if ((intptr_t) XSUBR (fun)->doc >= 0)
-       doc = build_string (XSUBR (fun)->doc);
-      else
-       doc = make_number ((intptr_t) XSUBR (fun)->doc);
-    }
+    doc = make_number (XSUBR (fun)->doc);
   else if (COMPILEDP (fun))
     {
       if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING)
@@ -473,7 +464,7 @@ aren't strings.  */)
 /* Scanning the DOC files and placing docstring offsets into functions.  */
 
 static void
-store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
+store_function_docstring (Lisp_Object obj, EMACS_INT offset)
 {
   /* Don't use indirect_function here, or defaliases will apply their
      docstrings to the base functions (Bug#2603).  */
@@ -481,15 +472,10 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
 
   /* The type determines where the docstring is stored.  */
 
-  /* Lisp_Subrs have a slot for it.  */
-  if (SUBRP (fun))
-    {
-      intptr_t negative_offset = - offset;
-      XSUBR (fun)->doc = (char *) negative_offset;
-    }
-
   /* If it's a lisp form, stick it in the form.  */
-  else if (CONSP (fun))
+  if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
+    fun = XCDR (fun);
+  if (CONSP (fun))
     {
       Lisp_Object tem;
 
@@ -503,10 +489,12 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
               correctness is quite delicate.  */
            XSETCAR (tem, make_number (offset));
        }
-      else if (EQ (tem, Qmacro))
-       store_function_docstring (XCDR (fun), offset);
     }
 
+  /* Lisp_Subrs have a slot for it.  */
+  else if (SUBRP (fun))
+    XSUBR (fun)->doc = offset;
+
   /* Bytecode objects sometimes have slots for it.  */
   else if (COMPILEDP (fun))
     {
@@ -870,16 +858,14 @@ Otherwise, return a new string.  */)
         \<foo> just sets the keymap used for \[cmd].  */
       else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<'))
        {
-         struct buffer *oldbuf;
-         ptrdiff_t start_idx;
+        {
          /* This is for computing the SHADOWS arg for describe_map_tree.  */
          Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
-         Lisp_Object earlier_maps;
          ptrdiff_t count = SPECPDL_INDEX ();
 
          strp += 2;            /* skip \{ or \< */
          start = strp;
-         start_idx = start - SDATA (string);
+         ptrdiff_t start_idx = start - SDATA (string);
 
          while ((strp - SDATA (string) < SBYTES (string))
                 && *strp != '}' && *strp != '>')
@@ -909,7 +895,7 @@ Otherwise, return a new string.  */)
            }
 
          /* Now switch to a temp buffer.  */
-         oldbuf = current_buffer;
+         struct buffer *oldbuf = current_buffer;
          set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
          /* This is for an unusual case where some after-change
             function uses 'format' or 'prin1' or something else that
@@ -934,7 +920,8 @@ Otherwise, return a new string.  */)
            {
              /* Get the list of active keymaps that precede this one.
                 If this one's not active, get nil.  */
-             earlier_maps = Fcdr (Fmemq (tem, Freverse (active_maps)));
+             Lisp_Object earlier_maps
+               = Fcdr (Fmemq (tem, Freverse (active_maps)));
              describe_map_tree (tem, 1, Fnreverse (earlier_maps),
                                 Qnil, 0, 1, 0, 0, 1);
            }
@@ -942,6 +929,7 @@ Otherwise, return a new string.  */)
          Ferase_buffer ();
          set_buffer_internal (oldbuf);
          unbind_to (count, Qnil);
+        }
 
        subst_string:
          start = SDATA (tem);
@@ -980,28 +968,12 @@ Otherwise, return a new string.  */)
          nchars++;
          changed = true;
        }
-      else if (! multibyte)
-       *bufp++ = *strp++, nchars++;
       else
        {
-         int len;
-         int ch = STRING_CHAR_AND_LENGTH (strp, len);
-         if ((ch == LEFT_SINGLE_QUOTATION_MARK
-              || ch == RIGHT_SINGLE_QUOTATION_MARK)
-             && quoting_style != CURVE_QUOTING_STYLE)
-           {
-             *bufp++ = ((ch == LEFT_SINGLE_QUOTATION_MARK
-                         && quoting_style == GRAVE_QUOTING_STYLE)
-                        ? '`' : '\'');
-             strp += len;
-             changed = true;
-           }
-         else
-           {
-             do
-               *bufp++ = *strp++;
-             while (--len != 0);
-           }
+         *bufp++ = *strp++;
+         if (multibyte)
+           while (! CHAR_HEAD_P (*strp))
+             *bufp++ = *strp++;
          nchars++;
        }
     }
@@ -1046,12 +1018,17 @@ syms_of_doc (void)
 
   DEFVAR_LISP ("text-quoting-style", Vtext_quoting_style,
                doc: /* Style to use for single quotes in help and messages.
-Its value should be a symbol.
+Its value should be a symbol.  It works by substituting certain single
+quotes for grave accent and apostrophe.  This is done in help output
+and in functions like `message' and `format-message'.  It is not done
+in `format'.
+
 `curve' means quote with curved single quotes \\=‘like this\\=’.
 `straight' means quote with straight apostrophes \\='like this\\='.
-`grave' means quote with grave accent and apostrophe \\=`like this\\='.
-The default value nil acts like `curve' if curved single quotes are
-displayable, and like `grave' otherwise.  */);
+`grave' means quote with grave accent and apostrophe \\=`like this\\=';
+i.e., do not alter quote marks.  The default value nil acts like
+`curve' if curved single quotes are displayable, and like `grave'
+otherwise.  */);
   Vtext_quoting_style = Qnil;
 
   DEFVAR_BOOL ("internal--text-quoting-flag", text_quoting_flag,