emacs-diffs
[Top][All Lists]
Advanced

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

master 95c0467: Simplify getting value of text-quoting-style (Bug#44471)


From: Stefan Kangas
Subject: master 95c0467: Simplify getting value of text-quoting-style (Bug#44471)
Date: Mon, 9 Nov 2020 15:10:11 -0500 (EST)

branch: master
commit 95c04675abb33c9a77e561e109348954e0d67c85
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    Simplify getting value of text-quoting-style (Bug#44471)
    
    * src/doc.c (text_quoting_style): Remove function by merging it...
    (Ftext_quoting_style): ...here.  Rename from Fget_quoting_style.
    (syms_of_doc): Update defsubr for Ftext_quoting_style.
    * src/lisp.h (enum text_quoting_style): Remove enum.
    * src/doprnt.c (doprnt):
    * src/editfns.c (styled_format):
    * lisp/help.el (substitute-command-keys): Update callers to use
    text-quoting-style.
---
 lisp/help.el  |  4 ++--
 src/doc.c     | 40 ++++++++++++++--------------------------
 src/doprnt.c  |  8 ++++----
 src/editfns.c |  6 +++---
 src/lisp.h    | 12 ------------
 5 files changed, 23 insertions(+), 47 deletions(-)

diff --git a/lisp/help.el b/lisp/help.el
index 466ff21..32ee84b 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1103,13 +1103,13 @@ Otherwise, return a new string (without any text 
properties)."
                       (describe-map-tree this-keymap t (nreverse earlier-maps)
                                          nil nil t nil nil t))))))))
              ;; 2. Handle quotes.
-             ((and (eq (get-quoting-style) 'curve)
+             ((and (eq (text-quoting-style) 'curve)
                    (or (and (= (following-char) ?\`)
                             (prog1 t (insert "‘")))
                        (and (= (following-char) ?')
                             (prog1 t (insert "’")))))
               (delete-char 1))
-             ((and (eq (get-quoting-style) 'straight)
+             ((and (eq (text-quoting-style) 'straight)
                    (= (following-char) ?\`))
               (insert "'")
               (delete-char 1))
diff --git a/src/doc.c b/src/doc.c
index f1ce266..5f23e3d 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -682,37 +682,25 @@ default_to_grave_quoting_style (void)
          && EQ (AREF (dv, 0), make_fixnum ('`')));
 }
 
-/* Return the current effective text quoting style.  */
-enum text_quoting_style
-text_quoting_style (void)
+DEFUN ("text-quoting-style", Ftext_quoting_style,
+       Stext_quoting_style, 0, 0, 0,
+       doc: /* Return the current effective text quoting style.
+See variable `text-quoting-style'.  */)
+  (void)
 {
+  /* Use grave accent and apostrophe `like this'.  */
   if (NILP (Vtext_quoting_style)
       ? default_to_grave_quoting_style ()
       : EQ (Vtext_quoting_style, Qgrave))
-    return GRAVE_QUOTING_STYLE;
+    return Qgrave;
+
+  /* Use apostrophes 'like this'.  */
   else if (EQ (Vtext_quoting_style, Qstraight))
-    return STRAIGHT_QUOTING_STYLE;
-  else
-    return CURVE_QUOTING_STYLE;
-}
+    return Qstraight;
 
-/* This is just a Lisp wrapper for text_quoting_style above.  */
-DEFUN ("get-quoting-style", Fget_quoting_style,
-       Sget_quoting_style, 0, 0, 0,
-       doc: /* Return the current effective text quoting style.
-See variable `text-quoting-style'.  */)
-  (void)
-{
-  switch (text_quoting_style ())
-    {
-    case STRAIGHT_QUOTING_STYLE:
-      return Qstraight;
-    case CURVE_QUOTING_STYLE:
-      return Qcurve;
-    case GRAVE_QUOTING_STYLE:
-    default:
-      return Qgrave;
-    }
+  /* Use curved single quotes ‘like this’.  */
+  else
+    return Qcurve;
 }
 
 
@@ -755,5 +743,5 @@ otherwise.  */);
   defsubr (&Sdocumentation);
   defsubr (&Sdocumentation_property);
   defsubr (&Ssnarf_documentation);
-  defsubr (&Sget_quoting_style);
+  defsubr (&Stext_quoting_style);
 }
diff --git a/src/doprnt.c b/src/doprnt.c
index ce259d0..9316497 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -199,7 +199,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format,
   /* Buffer we have got with malloc.  */
   char *big_buffer = NULL;
 
-  enum text_quoting_style quoting_style = text_quoting_style ();
+  Lisp_Object quoting_style = Ftext_quoting_style ();
 
   bufsize--;
 
@@ -482,13 +482,13 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char 
*format,
 
       char const *src;
       ptrdiff_t srclen;
-      if (quoting_style == CURVE_QUOTING_STYLE && fmtchar == '`')
+      if (EQ (quoting_style, Qcurve) && fmtchar == '`')
        src = uLSQM, srclen = sizeof uLSQM - 1;
-      else if (quoting_style == CURVE_QUOTING_STYLE && fmtchar == '\'')
+      else if (EQ (quoting_style, Qcurve) && fmtchar == '\'')
        src = uRSQM, srclen = sizeof uRSQM - 1;
       else
        {
-         if (quoting_style == STRAIGHT_QUOTING_STYLE && fmtchar == '`')
+         if (EQ (quoting_style, Qstraight) && fmtchar == '`')
            fmtchar = '\'';
          eassert (ASCII_CHAR_P (fmtchar));
          *bufptr++ = fmtchar;
diff --git a/src/editfns.c b/src/editfns.c
index aedab47..4104edd 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3154,7 +3154,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool 
message)
     if (STRINGP (args[i]) && STRING_MULTIBYTE (args[i]))
       multibyte = true;
 
-  int quoting_style = message ? text_quoting_style () : -1;
+  Lisp_Object quoting_style = message ? Ftext_quoting_style () : Qnil;
 
   ptrdiff_t ispec;
   ptrdiff_t nspec = 0;
@@ -3774,7 +3774,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool 
message)
          unsigned char str[MAX_MULTIBYTE_LENGTH];
 
          if ((format_char == '`' || format_char == '\'')
-             && quoting_style == CURVE_QUOTING_STYLE)
+             && EQ (quoting_style, Qcurve))
            {
              if (! multibyte)
                {
@@ -3785,7 +3785,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool 
message)
              convbytes = 3;
              new_result = true;
            }
-         else if (format_char == '`' && quoting_style == 
STRAIGHT_QUOTING_STYLE)
+         else if (format_char == '`' && EQ (quoting_style, Qstraight))
            {
              convsrc = "'";
              new_result = true;
diff --git a/src/lisp.h b/src/lisp.h
index cf33031..76d7420 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4497,18 +4497,6 @@ extern void set_initial_environment (void);
 extern void syms_of_callproc (void);
 
 /* Defined in doc.c.  */
-enum text_quoting_style
-  {
-    /* Use curved single quotes ‘like this’.  */
-    CURVE_QUOTING_STYLE,
-
-    /* Use grave accent and apostrophe  `like this'.  */
-    GRAVE_QUOTING_STYLE,
-
-    /* Use apostrophes 'like this'.  */
-    STRAIGHT_QUOTING_STYLE
-  };
-extern enum text_quoting_style text_quoting_style (void);
 extern Lisp_Object read_doc_string (Lisp_Object);
 extern Lisp_Object get_doc_string (Lisp_Object, bool, bool);
 extern void syms_of_doc (void);



reply via email to

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