aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Kangas2020-11-05 15:32:45 +0100
committerStefan Kangas2020-11-09 21:08:28 +0100
commit95c04675abb33c9a77e561e109348954e0d67c85 (patch)
tree840c90aa973fd8c054dac22ddd31724fe7a688cc /src
parenta08320f7234685cd84a18040556fd3f7eaacaf45 (diff)
downloademacs-95c04675abb33c9a77e561e109348954e0d67c85.tar.gz
emacs-95c04675abb33c9a77e561e109348954e0d67c85.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/doc.c40
-rw-r--r--src/doprnt.c8
-rw-r--r--src/editfns.c6
-rw-r--r--src/lisp.h12
4 files changed, 21 insertions, 45 deletions
diff --git a/src/doc.c b/src/doc.c
index f1ce266d39f..5f23e3d0bba 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -682,37 +682,25 @@ default_to_grave_quoting_style (void)
682 && EQ (AREF (dv, 0), make_fixnum ('`'))); 682 && EQ (AREF (dv, 0), make_fixnum ('`')));
683} 683}
684 684
685/* Return the current effective text quoting style. */ 685DEFUN ("text-quoting-style", Ftext_quoting_style,
686enum text_quoting_style 686 Stext_quoting_style, 0, 0, 0,
687text_quoting_style (void) 687 doc: /* Return the current effective text quoting style.
688See variable `text-quoting-style'. */)
689 (void)
688{ 690{
691 /* Use grave accent and apostrophe `like this'. */
689 if (NILP (Vtext_quoting_style) 692 if (NILP (Vtext_quoting_style)
690 ? default_to_grave_quoting_style () 693 ? default_to_grave_quoting_style ()
691 : EQ (Vtext_quoting_style, Qgrave)) 694 : EQ (Vtext_quoting_style, Qgrave))
692 return GRAVE_QUOTING_STYLE; 695 return Qgrave;
696
697 /* Use apostrophes 'like this'. */
693 else if (EQ (Vtext_quoting_style, Qstraight)) 698 else if (EQ (Vtext_quoting_style, Qstraight))
694 return STRAIGHT_QUOTING_STYLE; 699 return Qstraight;
695 else
696 return CURVE_QUOTING_STYLE;
697}
698 700
699/* This is just a Lisp wrapper for text_quoting_style above. */ 701 /* Use curved single quotes ‘like this’. */
700DEFUN ("get-quoting-style", Fget_quoting_style, 702 else
701 Sget_quoting_style, 0, 0, 0, 703 return Qcurve;
702 doc: /* Return the current effective text quoting style.
703See variable `text-quoting-style'. */)
704 (void)
705{
706 switch (text_quoting_style ())
707 {
708 case STRAIGHT_QUOTING_STYLE:
709 return Qstraight;
710 case CURVE_QUOTING_STYLE:
711 return Qcurve;
712 case GRAVE_QUOTING_STYLE:
713 default:
714 return Qgrave;
715 }
716} 704}
717 705
718 706
@@ -755,5 +743,5 @@ otherwise. */);
755 defsubr (&Sdocumentation); 743 defsubr (&Sdocumentation);
756 defsubr (&Sdocumentation_property); 744 defsubr (&Sdocumentation_property);
757 defsubr (&Ssnarf_documentation); 745 defsubr (&Ssnarf_documentation);
758 defsubr (&Sget_quoting_style); 746 defsubr (&Stext_quoting_style);
759} 747}
diff --git a/src/doprnt.c b/src/doprnt.c
index ce259d07cfe..93164977206 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -199,7 +199,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format,
199 /* Buffer we have got with malloc. */ 199 /* Buffer we have got with malloc. */
200 char *big_buffer = NULL; 200 char *big_buffer = NULL;
201 201
202 enum text_quoting_style quoting_style = text_quoting_style (); 202 Lisp_Object quoting_style = Ftext_quoting_style ();
203 203
204 bufsize--; 204 bufsize--;
205 205
@@ -482,13 +482,13 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format,
482 482
483 char const *src; 483 char const *src;
484 ptrdiff_t srclen; 484 ptrdiff_t srclen;
485 if (quoting_style == CURVE_QUOTING_STYLE && fmtchar == '`') 485 if (EQ (quoting_style, Qcurve) && fmtchar == '`')
486 src = uLSQM, srclen = sizeof uLSQM - 1; 486 src = uLSQM, srclen = sizeof uLSQM - 1;
487 else if (quoting_style == CURVE_QUOTING_STYLE && fmtchar == '\'') 487 else if (EQ (quoting_style, Qcurve) && fmtchar == '\'')
488 src = uRSQM, srclen = sizeof uRSQM - 1; 488 src = uRSQM, srclen = sizeof uRSQM - 1;
489 else 489 else
490 { 490 {
491 if (quoting_style == STRAIGHT_QUOTING_STYLE && fmtchar == '`') 491 if (EQ (quoting_style, Qstraight) && fmtchar == '`')
492 fmtchar = '\''; 492 fmtchar = '\'';
493 eassert (ASCII_CHAR_P (fmtchar)); 493 eassert (ASCII_CHAR_P (fmtchar));
494 *bufptr++ = fmtchar; 494 *bufptr++ = fmtchar;
diff --git a/src/editfns.c b/src/editfns.c
index aedab476146..4104edd77fd 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3154,7 +3154,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
3154 if (STRINGP (args[i]) && STRING_MULTIBYTE (args[i])) 3154 if (STRINGP (args[i]) && STRING_MULTIBYTE (args[i]))
3155 multibyte = true; 3155 multibyte = true;
3156 3156
3157 int quoting_style = message ? text_quoting_style () : -1; 3157 Lisp_Object quoting_style = message ? Ftext_quoting_style () : Qnil;
3158 3158
3159 ptrdiff_t ispec; 3159 ptrdiff_t ispec;
3160 ptrdiff_t nspec = 0; 3160 ptrdiff_t nspec = 0;
@@ -3774,7 +3774,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
3774 unsigned char str[MAX_MULTIBYTE_LENGTH]; 3774 unsigned char str[MAX_MULTIBYTE_LENGTH];
3775 3775
3776 if ((format_char == '`' || format_char == '\'') 3776 if ((format_char == '`' || format_char == '\'')
3777 && quoting_style == CURVE_QUOTING_STYLE) 3777 && EQ (quoting_style, Qcurve))
3778 { 3778 {
3779 if (! multibyte) 3779 if (! multibyte)
3780 { 3780 {
@@ -3785,7 +3785,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
3785 convbytes = 3; 3785 convbytes = 3;
3786 new_result = true; 3786 new_result = true;
3787 } 3787 }
3788 else if (format_char == '`' && quoting_style == STRAIGHT_QUOTING_STYLE) 3788 else if (format_char == '`' && EQ (quoting_style, Qstraight))
3789 { 3789 {
3790 convsrc = "'"; 3790 convsrc = "'";
3791 new_result = true; 3791 new_result = true;
diff --git a/src/lisp.h b/src/lisp.h
index cf33031342d..76d74200ac8 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4497,18 +4497,6 @@ extern void set_initial_environment (void);
4497extern void syms_of_callproc (void); 4497extern void syms_of_callproc (void);
4498 4498
4499/* Defined in doc.c. */ 4499/* Defined in doc.c. */
4500enum text_quoting_style
4501 {
4502 /* Use curved single quotes ‘like this’. */
4503 CURVE_QUOTING_STYLE,
4504
4505 /* Use grave accent and apostrophe `like this'. */
4506 GRAVE_QUOTING_STYLE,
4507
4508 /* Use apostrophes 'like this'. */
4509 STRAIGHT_QUOTING_STYLE
4510 };
4511extern enum text_quoting_style text_quoting_style (void);
4512extern Lisp_Object read_doc_string (Lisp_Object); 4500extern Lisp_Object read_doc_string (Lisp_Object);
4513extern Lisp_Object get_doc_string (Lisp_Object, bool, bool); 4501extern Lisp_Object get_doc_string (Lisp_Object, bool, bool);
4514extern void syms_of_doc (void); 4502extern void syms_of_doc (void);