From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: michael-franzese@gmx.com Newsgroups: gmane.emacs.help Subject: Re: Determining existence of text following point Date: Wed, 19 May 2021 09:28:45 +0200 Message-ID: References: <87cztpx8oz.fsf@ericabrahamsen.net> <87zgwsx5r3.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14158"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eric Abrahamsen , Skip Montanaro , Help Gnu Emacs To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 19 09:29:54 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ljGeQ-0003Ww-Il for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 09:29:54 +0200 Original-Received: from localhost ([::1]:42792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljGeO-0001wB-ND for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 03:29:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljGe3-0001vl-To for help-gnu-emacs@gnu.org; Wed, 19 May 2021 03:29:32 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:46083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljGe1-000435-Lw for help-gnu-emacs@gnu.org; Wed, 19 May 2021 03:29:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1621409325; bh=OniGNOj+RQZBmpgjCjAM4kDwH2a8YNjSbzHWhYQIWjY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=HDIIuC2d/X5LSTl4kgMp+Pdl3x5TTEyOF0ahQGt5dnOF7anVESxCknT33ZqL1oW1W e365xbtVxEp9TmOb9d2mY9aqhkn1ZUad+QUXNHMpnel6rCtScmK4mFTCzazOoowir7 vAg2BNZfbGku0q5iY7DMT56NUS+vg6Il+m4B4/Lc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs13.server.lan [172.19.170.181]) (via HTTP); Wed, 19 May 2021 09:28:45 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:adC3jULnAA+LKn/RyvKrmi4bvrY0YM0F51moQD42Ri9M8Gf1pct0titeRJSLWdSzS5DkV o3X26nenU/4iNDqxcCtdXL1Rd5wVtW/EPdsSY4XdjXGTcXX1Pxsy2Df+pQfoR0BDJHHpNzC2sKvj OFK1zxuV3pL5UUig2782vQBIlIIwmSr9qa09Cqa7zhR9HGbnm5+jYDsbVUbHHrJFItMKxphClQTq EaVF6G1/z359aRjnyDTsDRtF1kI3ZxGSeKH+kZ70wPEZklSaMooUpjSh9RS0sLIAsTss9QbktEb1 +g= X-UI-Out-Filterresults: notjunk:1;V03:K0:7ZuZe/2OlS4=:1SW2C8kuzc2DazwkzZQnhM ePJoE49TMC5nOonUyveiZogJ1buwhdDFryFAB+GAKQbb9KalzWg1OmEKP17kaFdr0Nh/kWPQy AsYy2FOjN7kDvv/Z3EevZjE7bgmLXZcmJkx1vS0m3dSIPnPg94tK9iRa6sfM4R5RcaKV2Ax5P uce0C3JLjHNVfy0MTofS+hQQUfGKZF2hTw7ptlAvSG8Kwea2vz5zM2zd3/ZWQMLyhvxsds1RY eYm5bUnoUtFpTqerjiFc8WQiYPBUX2HypG1/T7u8dSgQ9J33c0DovudXiEUP8bLOBLvg0oiZT 2hqh+FoA94hG2hLVImknWXx4W22blbCG475gf0D39rK779KNemRjZVAcnuW/R8jl/RGCK5PVu yb+UI+LT7tNUkMvBuhg5knJTdK+PeNMiAYX0A/s7dzucKr4sU6DrnR9IApMt+3sbr05lMrrNH BiY1MlEDihRdEapI6mSP3l1a1vhZ9vET/zoG30pD543PFpllnj2uqU/IdNcxyn6XpDzvs9I6j m8lXnPofZWd5voRmlOi1r5SevSMUihdZNJ7gWCyp+CiWQxgLhvOM+0i/uImQ0w59GrhHemVqX kopaKVUC8TV2aJCU2VpSni+3qymNLV9AmYzcjkwNCmLkRQbYqPB0JtDvU1f/PAUubtF+jZ2z5 GV4pSJiEiVajVUFEsvyE3mYqZ2chr1oCF39Dv8C2YtOmMGN36GP9jnuLg9U10bpgezzoRQ4Tv 3ebdfaxEpgJhKp/84sV5cmLd33nD5IiNgCA9P1m2eim/37nJSxZdbhsGCJD3T15vSyfDWY14 Received-SPF: pass client-ip=212.227.17.21; envelope-from=michael-franzese@gmx.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:129916 Archived-At: Point will always be at the beginning of a comment on a separate line The "^" shows the position of the cursor=2E ^;; ;;;;;;;;;;;;;;;;;;;;;;;;;; ^;; +++++++++++++++++++++++++++ ^;; ---------------------------- I want to have a keybinding that if I continue to hit will change a comment from ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to ;; +++++++++++++++++++++++++++++++++++++ Currently I have the following code (defun insert-bifurcation (s n) "todo" (let* ( (a (point)) (b (line-end-position)) (line-cut (buffer-substring-no-properties a b)) ) (when (or (not (string-match "[^[:blank:]]" line-cut)) (eolp)) (pcase n (0 (save-excursion (insert s)) (comment-region a b)) =20 ((or 1 2 3 4 5) (delete-region a b) (save-excursion (insert s)) (comment-region a b)) (_ (delete-region a b))) )) ) (defvar count 1) (defun insert-bifurcating-comment () "Insert bifurcating line at cursor position" (interactive) (let* ( (m 62) (n 69) (lena (- m (current-column))) ; lena =3D m - (current-column) (lenb (- n (current-column))) ) (pcase count (0 ;; makes s to be line with repeating ";" (setq-local s (make-string lena ?\;)) ; repeats lena times (insert-bifurcation s count) (setq-local count 1)) (1 ;; makes s to be line with repeating ";" (setq-local s (make-string lenb ?\;)) ; string length lenb (insert-bifurcation s count) (setq-local count 2)) (2 ;; makes s to be line with repeating "+" (setq-local s (make-string lena ?+)) (insert-bifurcation s count) (setq-local count 3)) (_ ;; deactivates the bifurcating line (insert-bifurcation s count) (setq-local count 1)) )) ) > Sent: Wednesday, May 19, 2021 at 10:17 AM > From: "Jean Louis" > To: michael-franzese@gmx=2Ecom > Cc: "Eric Abrahamsen" , "Skip Montanaro" , "Help Gnu Emacs" > Subject: Re: Determining existence of text following point > > * michael-franzese@gmx=2Ecom [2021-05-18 23= :52]: > > For instance, if the text in a commented string as follows, I will go = ahead with > > the insertion=2E > >=20 > (defun my-insert-on-empty-end-of-line (s) > (let ((line-cut (buffer-substring-no-properties (point) (line-end-posi= tion)))) > (when (or (not (string-match "[^[:blank:]]" line-cut)) (eolp)) > (insert s)))) >=20 > (defun my-insert-on-empty-end-of-line (s) > (let ((line-cut (buffer-substring-no-properties (point) (line-end-posi= tion)))) > (when (or (not (string-match "[^+[:blank:];-]" line-cut)) (eolp)) > (insert s)))) >=20 > (defun my-insert () > (interactive) > (my-insert-on-empty-end-of-line "Hello")) >=20 > (local-set-key (kbd "") 'my-insert) >=20 > Line with blanks, works: > ;; Hello =20 >=20 > Line with something else but our series of chars (does not work, expecte= d): >=20 > ;; =E2=96=88 abc >=20 > Line with fancy stuff that we wish to include (works): >=20 > ;; ;;;;;;;;;;;;;;;;Hello;;;;;;;;;;;;;;;;;;;;;; > ;; +++++++++++++++++++++Hello+++++++++++++ > ;; -------------------------Hello------Hello >=20 > Weird other lines (it does not work, as it is so expected): >=20 > ;; =F0=9D=93=92=F0=9D=93=BE=F0=9D=93=BB=F0=9D=93=BC=F0=9D=93=B8=F0=9D=93= =BB =F0=9D=93=B2=F0=9D=93=BC =F0=9D=93=B1=F0=9D=93=AE=F0=9D=93=BB=F0=9D=93= =AE: =E2=96=88 =F0=9D=93=AB=F0=9D=93=BE=F0=9D=93=BD =F0=9D=93=B2=F0=9D=93= =BC =F0=9D=93=B7=F0=9D=93=B8=F0=9D=93=BD =F0=9D=94=80=F0=9D=93=B8=F0=9D=93= =BB=F0=9D=93=B4=F0=9D=93=B2=F0=9D=93=B7=F0=9D=93=B0, =F0=9D=90=84=F0=9D=90= =97=F0=9D=90=8F=F0=9D=90=84=F0=9D=90=82=F0=9D=90=93=F0=9D=90=84=F0=9D=90=83= ! >=20 >=20 > --=20 > Jean >=20 > Take action in Free Software Foundation campaigns: > https://www=2Efsf=2Eorg/campaigns >=20 > Sign an open letter in support of Richard M=2E Stallman > https://stallmansupport=2Eorg/ > https://rms-support-letter=2Egithub=2Eio/ >=20 >=20 >