Subject: Re: bug#70984: 30.0.50; Improved support for entering quotation marks, Re: bug#70984: 30.0.50; Improved support for entering quotation marks

From: Robert Pluim <[email-masked]>
Date: Fri, 17 May 2024 14:15:31 +0200

>>>>> On Fri, 17 May 2024 13:44:12 +0300, Eli Zaretskii <[email-masked]> said:

    >> From: Robert Pluim <[email-masked]>
    >> Cc: Stephen Berman <[email-masked]>,  [email-masked]
    >> Date: Fri, 17 May 2024 09:45:14 +0200
    >> 
    >> Iʼm assuming this means youʼre both ok with the key sequences I chose.

    Eli> I don't have any objections, but I'm not going to be a frequent user
    Eli> of this, so I guess we'll let the users judge that.

Apropos, what about the following for electric-quote-chars? I think
Iʼve covered most of the common combinations:

diff --git a/lisp/electric.el b/lisp/electric.el
index fee0bf36d7f..406eac2f3a1 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -506,12 +506,55 @@ electric-quote-string
   :version "25.1"
   :type 'boolean :safe 'booleanp :group 'electricity)
 
+(define-widget 'electric-quote-chars-type 'lazy
+  "Display list of electric quote chars."
+  :group 'electricity
+  :format "%t:\n%v\n"
+  :type '(list (character :tag "Left single quote ")
+               (character :tag "Right single quote")
+               (character :tag "Left double quote ")
+               (character :tag "Right double quote")))
+
 (defcustom electric-quote-chars '(?‘ ?’ ?“ ?”)
   "Curved quote characters for `electric-quote-mode'.
 This list's members correspond to left single quote, right single
-quote, left double quote, and right double quote, respectively."
+quote, left double quote, and right double quote, respectively.
+
+There are predefined settings for common styles, or you can define
+your own custom style."
   :version "26.1"
-  :type '(list character character character character)
+  :type '(choice
+          ;; The countries and languages mentioned here are not intended
+          ;; to be an exhaustive list.
+          ;; US English, Canada, India, Brazil…, almost everywhere in
+          ;; fact.
+          (electric-quote-chars-type :tag "Default" (?‘ ?’ ?“ ?”))
+          ;; This style has ?“ and ?” as first level quotation,
+          ;; which is why they're on the single quote, not double quote.
+          ;; UK English
+          (electric-quote-chars-type :tag "Reversed" (?“ ?” ?‘ ?’ ))
+          ;; France
+          (electric-quote-chars-type :tag "Guillemets" (?« ?» ?« ?»))
+          ;; Switzerland
+          (electric-quote-chars-type :tag "Single/double guillemets" (?‹ ?› ?« ?»))
+          ;; Norway
+          (electric-quote-chars-type :tag "Single quote guillemets" (?‘ ?’ ?« ?»))
+          ;; Greece, Italy, Portugal
+          (electric-quote-chars-type :tag "Guillemets double quote" (?« ?» ?“ ?”))
+          ;; This style also has ?“ and ?” as first level quotation,
+          ;; Spain, Ukraine
+          (electric-quote-chars-type :tag "Double quote guillemets" (?“ ?” ?« ?» ))
+          ;; Hebrew, Sweden
+          (electric-quote-chars-type :tag "Right only" (?’ ?’ ?” ?”))
+          ;; Netherlands
+          (electric-quote-chars-type :tag "Low/high right only" (?‚ ?’ ?„ ?”))
+          ;; Germany
+          (electric-quote-chars-type :tag "Low/high right/left" (?‚ ?‘ ?„ ?“))
+          ;; Chinese, simplified.
+          (electric-quote-chars-type :tag "Corners" (?「 ?」 ?『 ?』))
+          ;; Chinese, traditional.
+          (electric-quote-chars-type :tag "Corners reversed" (?『 ?』?「 ?」))
+          (electric-quote-chars-type :tag "Custom" (?‘ ?’ ?“ ?”)))
   :safe (lambda (x)
           (pcase x
             (`(,(pred characterp) ,(pred characterp)

Robert
--