GNU bug report logs -
#78053
[PATCH] Support strings for electric-pairs.
Previous Next
To reply to this bug, email your comments to 78053 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
joaotavora <at> gmail.com, bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Fri, 25 Apr 2025 00:31:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Elijah Gabe Pérez <eg642616 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
joaotavora <at> gmail.com, bug-gnu-emacs <at> gnu.org
.
(Fri, 25 Apr 2025 00:31:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Tags: patch
As discussed in bug#77823, this feature bring support for
using strings as pairs in `electric-pair-mode', the advantage is that
this can be used for: Auto-close block comments, close conditional
constructs such as `case esac' from bash and whatever.
This is currently a working prototype (only inserts the pairs).
I would like to hear some comments or suggestions of this implementation.
Thanks.
[0001-Support-strings-for-electric-pairs.-bug.patch (text/patch, attachment)]
[Message part 3 (text/plain, inline)]
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sat, 10 May 2025 09:22:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 78053 <at> debbugs.gnu.org (full text, mbox):
> Cc: João Távora <joaotavora <at> gmail.com>
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Date: Thu, 24 Apr 2025 18:30:10 -0600
>
> As discussed in bug#77823, this feature bring support for
> using strings as pairs in `electric-pair-mode', the advantage is that
> this can be used for: Auto-close block comments, close conditional
> constructs such as `case esac' from bash and whatever.
>
> This is currently a working prototype (only inserts the pairs).
> I would like to hear some comments or suggestions of this implementation.
João, any comments?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sat, 24 May 2025 08:52:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 78053 <at> debbugs.gnu.org (full text, mbox):
Ping!
> Cc: 78053 <at> debbugs.gnu.org
> Date: Sat, 10 May 2025 12:21:28 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
>
> > Cc: João Távora <joaotavora <at> gmail.com>
> > From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> > Date: Thu, 24 Apr 2025 18:30:10 -0600
> >
> > As discussed in bug#77823, this feature bring support for
> > using strings as pairs in `electric-pair-mode', the advantage is that
> > this can be used for: Auto-close block comments, close conditional
> > constructs such as `case esac' from bash and whatever.
> >
> > This is currently a working prototype (only inserts the pairs).
> > I would like to hear some comments or suggestions of this implementation.
>
> João, any comments?
>
>
>
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sat, 24 May 2025 17:35:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 78053 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I already expressed my misgivings/opinion/ignorance about this in
bug#77823, no? Or am I figured and this a different matter altogether?
Just to clarify, electric-pair-mode already existed when I touched it and
it did some arguably interesting but not particularly stuff. I just added
the pair-based-on-syntax-while-helping-balance feature. This, as far as
I can tell, is a somewhat distinct area that isn't in my expertise.
My advice is to call Stefan.
João
On Sat, May 24, 2025, 09:51 Eli Zaretskii <eliz <at> gnu.org> wrote:
> Ping!
>
> > Cc: 78053 <at> debbugs.gnu.org
> > Date: Sat, 10 May 2025 12:21:28 +0300
> > From: Eli Zaretskii <eliz <at> gnu.org>
> >
> > > Cc: João Távora <joaotavora <at> gmail.com>
> > > From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> > > Date: Thu, 24 Apr 2025 18:30:10 -0600
> > >
> > > As discussed in bug#77823, this feature bring support for
> > > using strings as pairs in `electric-pair-mode', the advantage is that
> > > this can be used for: Auto-close block comments, close conditional
> > > constructs such as `case esac' from bash and whatever.
> > >
> > > This is currently a working prototype (only inserts the pairs).
> > > I would like to hear some comments or suggestions of this
> implementation.
> >
> > João, any comments?
> >
> >
> >
> >
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sun, 25 May 2025 06:28:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 78053 <at> debbugs.gnu.org (full text, mbox):
> From: João Távora <joaotavora <at> gmail.com>
> Date: Sat, 24 May 2025 18:34:10 +0100
> Cc: Elijah G <eg642616 <at> gmail.com>, 78053 <at> debbugs.gnu.org
>
> I already expressed my misgivings/opinion/ignorance about this in bug#77823, no? Or am I figured and this
> a different matter altogether?
I cannot find your comments in that bug. Could you reiterate your
opinions and comments?
> Just to clarify, electric-pair-mode already existed when I touched it and it did some arguably interesting but
> not particularly stuff. I just added the pair-based-on-syntax-while-helping-balance feature. This, as far as I
> can tell, is a somewhat distinct area that isn't in my expertise.
>
> My advice is to call Stefan.
Stefan, WDYT about this proposal?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sun, 25 May 2025 13:45:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 78053 <at> debbugs.gnu.org (full text, mbox):
> As discussed in bug#77823, this feature bring support for
> using strings as pairs in `electric-pair-mode',
Thank you for looking into it. I think this would be a nice addition to
`electric-pair-mode`.
> +---
> +** Electric pair mode now supports using strings as pairs.
> +Now 'electric-pair-mode' can use strings as pairs,
> +TODO: I don't know what to put here
The second line just repeats the first, so you can just remove it.
In general, this seems sufficient, tho maybe we should clarify the
"meaning" of using strings there. IOW, I'd say something like:
** Electric pair mode supports multicharacter paired delimiters.
This is done by supporting strings in 'electric-pair-pairs'.
> @@ -41,7 +41,9 @@ electric-pair-pairs
> See also the variable `electric-pair-text-pairs'."
> :version "24.1"
> :group 'electricity
> - :type '(repeat (cons character character)))
> + :type '(repeat
> + (choice (cons character character)
> + (cons string string))))
We want to do the same for `electric-pair-text-pairs`, no?
> @@ -258,7 +260,18 @@ electric-pair-syntax-info
> (direct (if (eq (car direct) (cdr direct))
> (list ?\" command-event t string-or-comment)
> (list ?\( (cdr direct) t string-or-comment)))
> - (reverse (list ?\) (car reverse) t string-or-comment)))))
> + (reverse (list ?\) (car reverse) t string-or-comment))
> + ;; The if-let here is for avoid unnecessary looking-back computation
> + ((if-let* ((str-pair
> + (cl-loop for pairs in fallback
> + do
> + (if (and
> + (stringp (car pairs))
> + (looking-back
> + (regexp-quote (car pairs))
> + (- (point) (length (car pairs)))))
> + (cl-return (cdr pairs))))))
> + (list 'str str-pair nil nil))))))
BTW, here you could use `compare-buffer-substrings`.
And you can get rid of the `if-let*` altogether by doing:
(t (cl-loop
for pairs in fallback
do (when {...}
(cl-return (list 'str ...))))))))
> (defun electric-pair--insert (char times)
> (let ((last-command-event char)
> @@ -591,6 +604,11 @@ electric-pair-post-self-insert-function
> pos))
> (forward-char num))
> ;; Insert matching pair.
> + ;; String pairs
> + ((and (eq syntax 'str) (not overwrite-mode))
> + (insert " ")
> + (save-excursion (insert " " pair)))
> + ;; Char pairs
> ((and (memq syntax '(?\( ?\" ?\$))
> (not overwrite-mode)
> (or unconditional
I can imagine some multi-char delimiters which don't call for spaces
inside of them (e.g. LaTeX's ``...''), so maybe the entries in
`electric-pair-pairs` should have some extra info about it.
I suggest we replace the (STRING . STRING) format with
(STRING STRING ...) so we can put extra info in the `...`.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sun, 25 May 2025 17:21:02 GMT)
Full text and
rfc822 format available.
Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:
>> (defun electric-pair--insert (char times)
>> (let ((last-command-event char)
>> @@ -591,6 +604,11 @@ electric-pair-post-self-insert-function
>> pos))
>> (forward-char num))
>> ;; Insert matching pair.
>> + ;; String pairs
>> + ((and (eq syntax 'str) (not overwrite-mode))
>> + (insert " ")
>> + (save-excursion (insert " " pair)))
>> + ;; Char pairs
>> ((and (memq syntax '(?\( ?\" ?\$))
>> (not overwrite-mode)
>> (or unconditional
>
> I can imagine some multi-char delimiters which don't call for spaces
> inside of them (e.g. LaTeX's ``...''), so maybe the entries in
> `electric-pair-pairs` should have some extra info about it.
> I suggest we replace the (STRING . STRING) format with
> (STRING STRING ...) so we can put extra info in the `...`.
See for example Java's text blocks:
The opening delimiter is a sequence of three double quote characters
(""") followed by zero or more white spaces followed by a line
terminator. The content begins at the first character after the line
terminator of the opening delimiter.
The closing delimiter is a sequence of three double quote
characters. The content ends at the last character before the first
double quote of the closing delimiter.
(https://openjdk.org/jeps/378) -- it would be nifty if the mandatory
linebreak was inserted automatically.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Mon, 26 May 2025 01:18:02 GMT)
Full text and
rfc822 format available.
Message #26 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:
>> @@ -41,7 +41,9 @@ electric-pair-pairs
>> See also the variable `electric-pair-text-pairs'."
>> :version "24.1"
>> :group 'electricity
>> - :type '(repeat (cons character character)))
>> + :type '(repeat
>> + (choice (cons character character)
>> + (cons string string))))
>
> We want to do the same for `electric-pair-text-pairs`, no?
>
Yes, I forgot it.
>> @@ -258,7 +260,18 @@ electric-pair-syntax-info
>> (direct (if (eq (car direct) (cdr direct))
>> (list ?\" command-event t string-or-comment)
>> (list ?\( (cdr direct) t string-or-comment)))
>> - (reverse (list ?\) (car reverse) t string-or-comment)))))
>> + (reverse (list ?\) (car reverse) t string-or-comment))
>> + ;; The if-let here is for avoid unnecessary looking-back computation
>> + ((if-let* ((str-pair
>> + (cl-loop for pairs in fallback
>> + do
>> + (if (and
>> + (stringp (car pairs))
>> + (looking-back
>> + (regexp-quote (car pairs))
>> + (- (point) (length (car pairs)))))
>> + (cl-return (cdr pairs))))))
>> + (list 'str str-pair nil nil))))))
>
> BTW, here you could use `compare-buffer-substrings`.
Thanks, Can you explain how to use it in this case? AFAIK
`compare-buffer-substrings' needs 2 strings in the buffer for the
comparison.
>> (defun electric-pair--insert (char times)
>> (let ((last-command-event char)
>> @@ -591,6 +604,11 @@ electric-pair-post-self-insert-function
>> pos))
>> (forward-char num))
>> ;; Insert matching pair.
>> + ;; String pairs
>> + ((and (eq syntax 'str) (not overwrite-mode))
>> + (insert " ")
>> + (save-excursion (insert " " pair)))
>> + ;; Char pairs
>> ((and (memq syntax '(?\( ?\" ?\$))
>> (not overwrite-mode)
>> (or unconditional
>
> I can imagine some multi-char delimiters which don't call for spaces
> inside of them (e.g. LaTeX's ``...''), so maybe the entries in
> `electric-pair-pairs` should have some extra info about it.
> I suggest we replace the (STRING . STRING) format with
> (STRING STRING ...) so we can put extra info in the `...`.
Are you sure it's good idea to replace the cons cell form with a list?
I've added the list form, but it coexists with the cons cell to avoid
any future bug.
[0001-Support-strings-for-electric-pairs.-bug-78053.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Mon, 26 May 2025 01:18:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Mon, 26 May 2025 16:04:01 GMT)
Full text and
rfc822 format available.
Message #32 received at 78053 <at> debbugs.gnu.org (full text, mbox):
>>> + ((if-let* ((str-pair
>>> + (cl-loop for pairs in fallback
>>> + do
>>> + (if (and
>>> + (stringp (car pairs))
>>> + (looking-back
>>> + (regexp-quote (car pairs))
>>> + (- (point) (length (car pairs)))))
>>> + (cl-return (cdr pairs))))))
>>> + (list 'str str-pair nil nil))))))
>>
>> BTW, here you could use `compare-buffer-substrings`.
>
> Thanks, Can you explain how to use it in this case? AFAIK
> `compare-buffer-substrings' needs 2 strings in the buffer for the
> comparison.
Duh, you're right, it can't be used here.
We should probably extend `compare-strings` to accept buffer arguments
and then obsolete `compare-buffer-substrings'.
>>> (defun electric-pair--insert (char times)
>>> (let ((last-command-event char)
>>> @@ -591,6 +604,11 @@ electric-pair-post-self-insert-function
>>> pos))
>>> (forward-char num))
>>> ;; Insert matching pair.
>>> + ;; String pairs
>>> + ((and (eq syntax 'str) (not overwrite-mode))
>>> + (insert " ")
>>> + (save-excursion (insert " " pair)))
>>> + ;; Char pairs
>>> ((and (memq syntax '(?\( ?\" ?\$))
>>> (not overwrite-mode)
>>> (or unconditional
>>
>> I can imagine some multi-char delimiters which don't call for spaces
>> inside of them (e.g. LaTeX's ``...''), so maybe the entries in
>> `electric-pair-pairs` should have some extra info about it.
>> I suggest we replace the (STRING . STRING) format with
>> (STRING STRING ...) so we can put extra info in the `...`.
>
> Are you sure it's good idea to replace the cons cell form with a list?
We need to keep supporting the (CHAR . CHAR) form, of course, but yes,
I think using (STRING STRING . PROPERTIES) is a better option than
(STRING . STRING) and there is no backward compatibility need to
support (STRING . STRING).
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sat, 07 Jun 2025 08:40:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 78053 <at> debbugs.gnu.org (full text, mbox):
> Cc: 78053 <at> debbugs.gnu.org,
> João Távora <joaotavora <at> gmail.com>
> Date: Mon, 26 May 2025 12:03:00 -0400
> From: Stefan Monnier via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> >>> + ((if-let* ((str-pair
> >>> + (cl-loop for pairs in fallback
> >>> + do
> >>> + (if (and
> >>> + (stringp (car pairs))
> >>> + (looking-back
> >>> + (regexp-quote (car pairs))
> >>> + (- (point) (length (car pairs)))))
> >>> + (cl-return (cdr pairs))))))
> >>> + (list 'str str-pair nil nil))))))
> >>
> >> BTW, here you could use `compare-buffer-substrings`.
> >
> > Thanks, Can you explain how to use it in this case? AFAIK
> > `compare-buffer-substrings' needs 2 strings in the buffer for the
> > comparison.
>
> Duh, you're right, it can't be used here.
> We should probably extend `compare-strings` to accept buffer arguments
> and then obsolete `compare-buffer-substrings'.
>
> >>> (defun electric-pair--insert (char times)
> >>> (let ((last-command-event char)
> >>> @@ -591,6 +604,11 @@ electric-pair-post-self-insert-function
> >>> pos))
> >>> (forward-char num))
> >>> ;; Insert matching pair.
> >>> + ;; String pairs
> >>> + ((and (eq syntax 'str) (not overwrite-mode))
> >>> + (insert " ")
> >>> + (save-excursion (insert " " pair)))
> >>> + ;; Char pairs
> >>> ((and (memq syntax '(?\( ?\" ?\$))
> >>> (not overwrite-mode)
> >>> (or unconditional
> >>
> >> I can imagine some multi-char delimiters which don't call for spaces
> >> inside of them (e.g. LaTeX's ``...''), so maybe the entries in
> >> `electric-pair-pairs` should have some extra info about it.
> >> I suggest we replace the (STRING . STRING) format with
> >> (STRING STRING ...) so we can put extra info in the `...`.
> >
> > Are you sure it's good idea to replace the cons cell form with a list?
>
> We need to keep supporting the (CHAR . CHAR) form, of course, but yes,
> I think using (STRING STRING . PROPERTIES) is a better option than
> (STRING . STRING) and there is no backward compatibility need to
> support (STRING . STRING).
Is the last patch okay to install? If not, Elijah, would you please
submit an updated patch?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sun, 08 Jun 2025 18:26:02 GMT)
Full text and
rfc822 format available.
Message #38 received at 78053 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
> Is the last patch okay to install? If not, Elijah, would you please
> submit an updated patch?
Sure, I'm sending here a better version.
I made a few minor changes since I found several bugs.
If there are no objections, the patch is ready to be installed.
[0001-Support-strings-for-electric-pairs.-Bug-78053.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Thu, 12 Jun 2025 07:36:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 78053 <at> debbugs.gnu.org (full text, mbox):
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 78053 <at> debbugs.gnu.org,
> joaotavora <at> gmail.com
> Date: Sun, 08 Jun 2025 12:24:57 -0600
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > Is the last patch okay to install? If not, Elijah, would you please
> > submit an updated patch?
>
> Sure, I'm sending here a better version.
>
> I made a few minor changes since I found several bugs.
> If there are no objections, the patch is ready to be installed.
Thanks, a few further minor comments:
> +---
> +** Electric pair mode now supports multi-character paired delimiters.
> +This is done by supporting strings in electric-pair-pairs.
the last sentence should be rewritten to tell users how to use this
feature instead of how it was implemented. For example:
To use this, customize 'electric-pair-pairs' to include the
delimiter strings.
(Note that this also quotes symbols, like we do in NEWS.)
> See also the variable `electric-pair-text-pairs'."
> :version "24.1"
> :group 'electricity
> - :type '(repeat (cons character character)))
> + :type '(repeat
> + (choice (cons :tag "Characters" character character)
> + (cons :tag "Strings" string string)
> + (list :tag "Strings and insert space in pairs"
> + string string boolean))))
What does "Strings and insert space in pairs" mean? This tag is IMO
unclear, and we should clarify it.
> @@ -51,10 +57,16 @@ electric-pair-text-pairs
>
> Pairs of delimiters in this list are a fallback in case they have
> no syntax relevant to `electric-pair-mode' in the syntax table
> -defined in `electric-pair-text-syntax-table'."
> +defined in `electric-pair-text-syntax-table'.
> +
> +NOTE: In string pairs, the first pair is a regular expression."
> :version "24.4"
> :group 'electricity
> - :type '(repeat (cons character character)))
> + :type '(repeat
> + (choice (cons :tag "Characters" character character)
> + (cons :tag "Strings" string string)
> + (list :tag "Strings and insert space in pairs"
> + string string boolean))))
Likewise here.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Thu, 12 Jun 2025 07:48:02 GMT)
Full text and
rfc822 format available.
Message #44 received at submit <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
>> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 78053 <at> debbugs.gnu.org,
>> joaotavora <at> gmail.com
>> Date: Sun, 08 Jun 2025 12:24:57 -0600
>>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>> > Is the last patch okay to install? If not, Elijah, would you please
>> > submit an updated patch?
>>
>> Sure, I'm sending here a better version.
>>
>> I made a few minor changes since I found several bugs.
>> If there are no objections, the patch is ready to be installed.
>
> Thanks, a few further minor comments:
>
>> +---
>> +** Electric pair mode now supports multi-character paired delimiters.
>> +This is done by supporting strings in electric-pair-pairs.
>
> the last sentence should be rewritten to tell users how to use this
> feature instead of how it was implemented. For example:
>
> To use this, customize 'electric-pair-pairs' to include the
> delimiter strings.
>
> (Note that this also quotes symbols, like we do in NEWS.)
>
>> See also the variable `electric-pair-text-pairs'."
>> :version "24.1"
>> :group 'electricity
>> - :type '(repeat (cons character character)))
>> + :type '(repeat
>> + (choice (cons :tag "Characters" character character)
>> + (cons :tag "Strings" string string)
>> + (list :tag "Strings and insert space in pairs"
>> + string string boolean))))
>
> What does "Strings and insert space in pairs" mean? This tag is IMO
> unclear, and we should clarify it.
FWIW, I'd love to have this customizable instead of being a hard-coded
space character. The use case is the multi-line strings of recent Java
versions, which start with three quotation marks (") and a mandatory
line break, and end with three quotation marks.
String exampleString = """
This is a muli-line Java string. The shortest sequence of leading
white space (4 spaces in this case) will be ignored.
""";
It would be nice if, in java-mode, after typing three quotation marks
the buffer would end up like this (with "|" denoting the cursor
position):
String exampleString = """
|"""
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sun, 15 Jun 2025 04:36:01 GMT)
Full text and
rfc822 format available.
Message #47 received at 78053 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> See also the variable `electric-pair-text-pairs'."
>> :version "24.1"
>> :group 'electricity
>> - :type '(repeat (cons character character)))
>> + :type '(repeat
>> + (choice (cons :tag "Characters" character character)
>> + (cons :tag "Strings" string string)
>> + (list :tag "Strings and insert space in pairs"
>> + string string boolean))))
>
> What does "Strings and insert space in pairs" mean? This tag is IMO
> unclear, and we should clarify it.
This is a kind of property for pairs (only for strings pairs), that
tells to `electric-pairs` to insert a space before the first pair.
I couldn't find a better way to document this in that limited-size tag.
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sun, 15 Jun 2025 04:43:05 GMT)
Full text and
rfc822 format available.
Message #50 received at 78053 <at> debbugs.gnu.org (full text, mbox):
Rudolf Schlatte <rudi <at> constantly.at> writes:
> FWIW, I'd love to have this customizable instead of being a hard-coded
> space character. The use case is the multi-line strings of recent Java
> versions, which start with three quotation marks (") and a mandatory
> line break, and end with three quotation marks.
>
> String exampleString = """
> This is a muli-line Java string. The shortest sequence of leading
> white space (4 spaces in this case) will be ignored.
> """;
>
> It would be nice if, in java-mode, after typing three quotation marks
> the buffer would end up like this (with "|" denoting the cursor
> position):
>
> String exampleString = """
> |"""
In my tests that behavior is possible.
Ofc, this kind of pairs is limited to comparasion of characters one
(this only inserts), but I think it's more than enough for most cases.
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sun, 15 Jun 2025 04:47:02 GMT)
Full text and
rfc822 format available.
Message #53 received at 78053 <at> debbugs.gnu.org (full text, mbox):
Elijah Gabe Pérez <eg642616 <at> gmail.com> writes:
> This is a kind of property for pairs (only for strings pairs), that
> tells to `electric-pairs` to insert a space before the first pair.
^^^^^^
Sorry, i meant after.
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sun, 15 Jun 2025 05:52:02 GMT)
Full text and
rfc822 format available.
Message #56 received at 78053 <at> debbugs.gnu.org (full text, mbox):
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: 78053 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
> Date: Sat, 14 Jun 2025 22:35:26 -0600
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> See also the variable `electric-pair-text-pairs'."
> >> :version "24.1"
> >> :group 'electricity
> >> - :type '(repeat (cons character character)))
> >> + :type '(repeat
> >> + (choice (cons :tag "Characters" character character)
> >> + (cons :tag "Strings" string string)
> >> + (list :tag "Strings and insert space in pairs"
> >> + string string boolean))))
> >
> > What does "Strings and insert space in pairs" mean? This tag is IMO
> > unclear, and we should clarify it.
>
> This is a kind of property for pairs (only for strings pairs), that
> tells to `electric-pairs` to insert a space before the first pair.
>
> I couldn't find a better way to document this in that limited-size tag.
If you explain to me what it does, I can try finding more clear
wording.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Sun, 15 Jun 2025 19:56:02 GMT)
Full text and
rfc822 format available.
Message #59 received at 78053 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> This is a kind of property for pairs (only for strings pairs), that
>> tells to `electric-pairs` to insert a space before the first pair.
>>
>> I couldn't find a better way to document this in that limited-size tag.
>
> If you explain to me what it does, I can try finding more clear
> wording.
That must be a list of 3 elements where specifies: pair start, pair end,
and a non-nil value which specifies to insert an extra space after `pair
start` was typed.
Thus, if electric-pair-pairs is set like this:
(setq electric-pair-pairs '(("/*" " */" t)))
After the pair start was typed it expands to this:
/* | */
^ cursor
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Mon, 16 Jun 2025 05:47:02 GMT)
Full text and
rfc822 format available.
Message #62 received at submit <at> debbugs.gnu.org (full text, mbox):
Elijah Gabe Pérez <eg642616 <at> gmail.com> writes:
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> This is a kind of property for pairs (only for strings pairs), that
>>> tells to `electric-pairs` to insert a space before the first pair.
>>>
>>> I couldn't find a better way to document this in that limited-size tag.
>>
>> If you explain to me what it does, I can try finding more clear
>> wording.
>
> That must be a list of 3 elements where specifies: pair start, pair end,
> and a non-nil value which specifies to insert an extra space after `pair
> start` was typed.
>
> Thus, if electric-pair-pairs is set like this:
> (setq electric-pair-pairs '(("/*" " */" t)))
>
> After the pair start was typed it expands to this:
> /* | */
> ^ cursor
Instead of hard-coding the extra space, how about allowing the third
element to also be a string, with that string being inserted after the
pair start? In java-mode, I'd then add an element ("\"\"\"" "\"\"\""
"\n") since Java-style multi-line strings start with a mandatory
linebreak after the opening triple-quote.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Mon, 16 Jun 2025 09:21:02 GMT)
Full text and
rfc822 format available.
Message #65 received at 78053 <at> debbugs.gnu.org (full text, mbox):
> From: Rudolf Schlatte <rudi <at> constantly.at>
> Date: Mon, 16 Jun 2025 07:46:25 +0200
>
> > Thus, if electric-pair-pairs is set like this:
> > (setq electric-pair-pairs '(("/*" " */" t)))
> >
> > After the pair start was typed it expands to this:
> > /* | */
> > ^ cursor
>
> Instead of hard-coding the extra space, how about allowing the third
> element to also be a string, with that string being inserted after the
> pair start? In java-mode, I'd then add an element ("\"\"\"" "\"\"\""
> "\n") since Java-style multi-line strings start with a mandatory
> linebreak after the opening triple-quote.
If that the Java style, then comment-start should include the newline,
no?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Mon, 16 Jun 2025 09:27:02 GMT)
Full text and
rfc822 format available.
Message #68 received at 78053 <at> debbugs.gnu.org (full text, mbox):
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: 78053 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
> Date: Sun, 15 Jun 2025 13:54:51 -0600
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> This is a kind of property for pairs (only for strings pairs), that
> >> tells to `electric-pairs` to insert a space before the first pair.
> >>
> >> I couldn't find a better way to document this in that limited-size tag.
> >
> > If you explain to me what it does, I can try finding more clear
> > wording.
>
> That must be a list of 3 elements where specifies: pair start, pair end,
> and a non-nil value which specifies to insert an extra space after `pair
> start` was typed.
>
> Thus, if electric-pair-pairs is set like this:
> (setq electric-pair-pairs '(("/*" " */" t)))
>
> After the pair start was typed it expands to this:
> /* | */
> ^ cursor
OK, but this should be first described in the doc string, which should
include the full documentation of the supported forms of the value.
As for the :tag text how about the below?
"Strings, plus insert SPC after first string"
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Mon, 16 Jun 2025 09:41:01 GMT)
Full text and
rfc822 format available.
Message #71 received at 78053 <at> debbugs.gnu.org (full text, mbox):
> On 16 Jun 2025, at 11:20, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> From: Rudolf Schlatte <rudi <at> constantly.at>
>> Date: Mon, 16 Jun 2025 07:46:25 +0200
>>
>>> Thus, if electric-pair-pairs is set like this:
>>> (setq electric-pair-pairs '(("/*" " */" t)))
>>>
>>> After the pair start was typed it expands to this:
>>> /* | */
>>> ^ cursor
>>
>> Instead of hard-coding the extra space, how about allowing the third
>> element to also be a string, with that string being inserted after the
>> pair start? In java-mode, I'd then add an element ("\"\"\"" "\"\"\""
>> "\n") since Java-style multi-line strings start with a mandatory
>> linebreak after the opening triple-quote.
>
> If that the Java style, then comment-start should include the newline,
> no?
That would also work, yes, just a little less “electrical”: If the auto-insert string after the opening sequence can’t be configured, I’d use an entry ("\"\"\"" "\"\"\”" NIL) for Java mode. This is how smartparens (https://github.com/Fuco1/smartparens) currently works: after three quotation marks you immediately get the matching closing quotation mark triple but have to press RETURN afterwards.
Anyway it’s not a big deal; please don’t let me block the patch going in. I’m looking forward to having multi-character electric pairs built in!
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Mon, 16 Jun 2025 22:41:04 GMT)
Full text and
rfc822 format available.
Message #74 received at 78053 <at> debbugs.gnu.org (full text, mbox):
Rudolf Schlatte <rudi <at> constantly.at> writes:
> Elijah Gabe Pérez <eg642616 <at> gmail.com> writes:
>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>>>> This is a kind of property for pairs (only for strings pairs),
>>>> that
>>>> tells to `electric-pairs` to insert a space before the first pair.
>>>>
>>>> I couldn't find a better way to document this in that limited-size
>>>> tag.
>>>
>>> If you explain to me what it does, I can try finding more clear
>>> wording.
>>
>> That must be a list of 3 elements where specifies: pair start, pair
>> end,
>> and a non-nil value which specifies to insert an extra space after
>> `pair
>> start` was typed.
>>
>> Thus, if electric-pair-pairs is set like this:
>> (setq electric-pair-pairs '(("/*" " */" t)))
>>
>> After the pair start was typed it expands to this:
>> /* | */
>> ^ cursor
>
> Instead of hard-coding the extra space, how about allowing the third
> element to also be a string, with that string being inserted after the
> pair start? In java-mode, I'd then add an element ("\"\"\"" "\"\"\""
> "\n") since Java-style multi-line strings start with a mandatory
> linebreak after the opening triple-quote.
That is already possible setting it to this:
("\"\"\" . "\n\"\"\"")
^^
The extra space option is not hardcoded and can be ignored in the
electric-pairs alist.
That is done for center the cursor when some pairs requires extra spaces
(mostly because style), I find it useful for most block comments
(e.g. C /* | */), but there may be more cases where this can also be useful
So there's no need to add another option to the list.
--
- E.G via GNU Emacs Android port.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78053
; Package
emacs
.
(Tue, 17 Jun 2025 00:57:02 GMT)
Full text and
rfc822 format available.
Message #77 received at 78053 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
[...]
>>
>> After the pair start was typed it expands to this:
>> /* | */
>> ^ cursor
>
> OK, but this should be first described in the doc string, which should
> include the full documentation of the supported forms of the value.
>
> As for the :tag text how about the below?
>
> "Strings, plus insert SPC after first string"
Thanks, It sounds better.
I've now updated the patch (plus added some new ert tests).
[0001-Support-strings-for-electric-pairs.-Bug-78053.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
--
- E.G via GNU Emacs and Org.
This bug report was last modified 1 day ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.