all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Make c-ts-mode-toggle-comment-style match it's docstring.
@ 2023-02-27 15:15 Felix
  2023-02-28 13:39 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Felix @ 2023-02-27 15:15 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 65 bytes --]


Implement the optional numeric arg mentioned in the docstring.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: c-ts-comment.patch --]
[-- Type: text/x-patch, Size: 1450 bytes --]

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 035df909eb2..9d4021866f0 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -87,19 +87,23 @@ c-ts-mode-indent-offset
   :safe 'integerp
   :group 'c)

-(defun c-ts-mode-toggle-comment-style ()
+(defun c-ts-mode-toggle-comment-style (&optional arg)
   "Toggle the comment style between block and line comments.
 Optional numeric ARG, if supplied, switches to block comment
 style when positive, to line comment style when negative, and
 just toggles it when zero or left out."
-  (interactive)
-  (pcase-let ((`(,starter . ,ender)
-               (if (string= comment-start "// ")
-                   (cons "/* " " */")
-                 (cons "// " ""))))
-    (setq-local comment-start starter
-                comment-end ender))
-  (c-ts-mode-set-modeline))
+  (interactive "P")
+  (let ((prevstate-line (string= comment-start "// ")))
+    (when (or (not arg)
+              (zerop (setq arg (prefix-numeric-value arg)))
+              (xor (> 0 arg) prevstate-line))
+      (pcase-let ((`(,starter . ,ender)
+                   (if prevstate-line
+                       (cons "/* " " */")
+                     (cons "// " ""))))
+        (setq-local comment-start starter
+                    comment-end ender))
+      (c-ts-mode-set-modeline))))

 (defun c-ts-mode-set-modeline ()
   (setq mode-name

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make c-ts-mode-toggle-comment-style match it's docstring.
  2023-02-27 15:15 [PATCH] Make c-ts-mode-toggle-comment-style match it's docstring Felix
@ 2023-02-28 13:39 ` Eli Zaretskii
  2023-02-28 16:22   ` Felix
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2023-02-28 13:39 UTC (permalink / raw)
  To: Felix; +Cc: emacs-devel

> From: Felix <felix.dick@web.de>
> Date: Mon, 27 Feb 2023 16:15:02 +0100
> 
> Implement the optional numeric arg mentioned in the docstring.

Thanks, installed on the emacs-29 branch.

This contribution all but exhausts the amount of code we can accept
from you without a copyright assignment.  Would you like to start your
legal paperwork at this time, so that you could keep sending
contributions without limitation?  If yes, I will send you the form to
fill.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make c-ts-mode-toggle-comment-style match it's docstring.
  2023-02-28 13:39 ` Eli Zaretskii
@ 2023-02-28 16:22   ` Felix
  2023-02-28 16:52     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Felix @ 2023-02-28 16:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel


Eli Zaretskii <eliz@gnu.org> writes:

>> From: Felix <felix.dick@web.de>
>> Date: Mon, 27 Feb 2023 16:15:02 +0100
>>
>> Implement the optional numeric arg mentioned in the docstring.
>
> Thanks, installed on the emacs-29 branch.
>
> This contribution all but exhausts the amount of code we can accept
> from you without a copyright assignment.  Would you like to start your
> legal paperwork at this time, so that you could keep sending
> contributions without limitation?  If yes, I will send you the form to
> fill.

First of all, thanks for reviewing and accepting my patches!
Tiny as they are, the fact that they are now part of Emacs means a lot to me :)
And yes, please send me the form.
Thanks again!



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make c-ts-mode-toggle-comment-style match it's docstring.
  2023-02-28 16:22   ` Felix
@ 2023-02-28 16:52     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2023-02-28 16:52 UTC (permalink / raw)
  To: Felix; +Cc: emacs-devel

> From: Felix <felix.dick@web.de>
> Cc: emacs-devel@gnu.org
> Date: Tue, 28 Feb 2023 17:22:02 +0100
> 
> > This contribution all but exhausts the amount of code we can accept
> > from you without a copyright assignment.  Would you like to start your
> > legal paperwork at this time, so that you could keep sending
> > contributions without limitation?  If yes, I will send you the form to
> > fill.
> 
> First of all, thanks for reviewing and accepting my patches!
> Tiny as they are, the fact that they are now part of Emacs means a lot to me :)

Thank you for your contributions and for your interest in Emacs in
general.

> And yes, please send me the form.

Form sent off-list.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-28 16:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27 15:15 [PATCH] Make c-ts-mode-toggle-comment-style match it's docstring Felix
2023-02-28 13:39 ` Eli Zaretskii
2023-02-28 16:22   ` Felix
2023-02-28 16:52     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.