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 10:05:30 +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="897"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eric Abrahamsen , Skip Montanaro , Help Gnu Emacs , Jean Louis To: michael-franzese@gmx.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 19 10:06:59 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 1ljHEI-000AWJ-F6 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 10:06:58 +0200 Original-Received: from localhost ([::1]:59632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljHEH-0006yd-Fr for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 04:06:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljHDc-0006yG-K6 for help-gnu-emacs@gnu.org; Wed, 19 May 2021 04:06:16 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:40717) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljHDa-0002r3-1y for help-gnu-emacs@gnu.org; Wed, 19 May 2021 04:06:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1621411530; bh=gc1FLnzfxx+bx78eN6OQTN2dM6ecA4HlS1Bt78cUYlg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=crX1bHUBrm2tkra2GmntUEIIRDrm0xEguVW/eBN8ZKR/oXxFUmd3QVrvWgUVRjGq6 4FbolopY7O7xYgV1AShIqCIYRMI0er8s264dSO8qYe8EToF5DX5bMxdjlLt7tvNICN DXc9VlfEqECVyizfZaPzm+w9tPTeStH1dD6nwzuo= 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-bs08.server.lan [172.19.170.176]) (via HTTP); Wed, 19 May 2021 10:05:30 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:2ngXFFMkLMOhdbB1xNej3HbpubXz/omibqpAF8HS+ajSAvZQ93bJdqwRiyNnpfwwntUQR 6RS1rsxnFoLlL7SVQ4i0KjFdVKSwXuKxnynG3jAtZo6I2+HaCH1AWbV+etWjmNggU0u6YrXXSoZz JMuU+ePgjd5vyA2UkOHLL+vWvqPWBIPJWFcsnV4xqW1euuW7neDbWPG+0Mg8trjhWriILj3qJfpj b99RJDx9/FB6EBPM9V7S8EsUA4lyoX7zV37oYA2gKcjyHFac4n71GnBuEB0yceSxNLu9e2AcUb/g +M= X-UI-Out-Filterresults: notjunk:1;V03:K0:QnMJx0Fo5UA=:cKYnAxtyWXnXCcZCVIoOX7 V2Hhz3Uxx+NGcjcBB4lS9xt2ZNTrkH5FMwNZsXnf0z1xX8qQU9qnyBqlZkaxqGg7IVOf9AydY xSrwrZIknUA99pczueXt60cxklFjkJcXQTCiqhAiyWTJPAV++3KPhXwC4U3Vg4j4U6rHlDgEk 57V8WT2uUVZKH1J3EylgAYu+QJAs3X1lzaYWVnNMWOArZTkQte62h6ySZ7rnD7AZhzqFphWS5 4eK9jGeFFxAICORB08rf8kukTyO/veIMmdBhHqNEdgJ0vlDZ+k3MDcy1KE7n4I9HyT4gN/Bx+ 28fBn2q04e2NIuHeOcO+hdVypM0XAsHxLdfc6C9qmInpXfDRtSAmDcYfMWmuCydn8OURMcSQJ /j9TBdH+otDn9fFWn7FoJl0EpZOwT3pyHvcreZ5zCGFxG8gPNt1sY4PxJ3Pj/2XtIlAgEX2QR X9A6VMoJ/Dmr5H36LhUQEEvAjZF7HlBWUoEyXv1rjAbf0i6te2n9ScIvOzldUC9fmbbIErgZ7 rmXnewTKpHWBo80JzI40DpK9Ito4ZwQl4VuhpyVj0LABdEMtvUFw+hyfmu1OdESYG5MMtQWB1 ubQiWRHceaLgmaEM8cX2P+VOp/lIZY/mEjICrxMBIl2u/NLKYrRkJ7KYxQYMJw+bOYKUuHIW9 zJRN9l3voVyPpFuvbpyOZ/WxudN1pDWO2KeTxnN9C9PZ0AgwXHOydnnjVNOID+7FjRUAMM739 jzJbBf69T22cyD7KoSiGMpRGTl5buYiPqtWqVmrOYP4fh4fb80zMQ60CQx78Q1N/1RQfUvzX Received-SPF: pass client-ip=212.227.15.19; 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:129920 Archived-At: Have made some simplifications to the code=2E I would also like to handle the following case=2E ;; =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E > Sent: Wednesday, May 19, 2021 at 7:28 PM > From: michael-franzese@gmx=2Ecom > To: "Jean Louis" > Cc: "Eric Abrahamsen" , "Skip Montanaro" , "Help Gnu Emacs" > Subject: Re: Determining existence of text following point > > Point will always be at the beginning of a comment on a separate line >=20 > The "^" shows the position of the cursor=2E >=20 > ^;; ;;;;;;;;;;;;;;;;;;;;;;;;;; >=20 > ^;; +++++++++++++++++++++++++++ >=20 > ^;; ---------------------------- >=20 > I want to have a keybinding that if I continue to hit will change > a comment from >=20 > ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >=20 > to >=20 > ;; +++++++++++++++++++++++++++++++++++++ >=20 > Currently I have the following code >=20 >=20 > (defun insert-bifurcation (s n) > "todo" >=20 > (let* ( (a (point)) (b (line-end-position)) > (line-cut (buffer-substring-no-properties a b)) ) >=20 > (when (or (not (string-match > "[^[:blank:]]" line-cut)) (eolp)) > (pcase n >=20 > (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)) >=20 > (_ > (delete-region a b))) )) ) >=20 > (defvar count 1) >=20 > (defun insert-bifurcating-comment () > "Insert bifurcating line at cursor position" > (interactive) >=20 > (let* ( (m 62) (n 69) > (lena (- m (current-column))) ; lena =3D m - (current-column) > (lenb (- n (current-column))) ) >=20 > (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)) )) ) >=20 >=20 >=20 >=20 >=20 >=20 > > 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 g= o 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-po= sition)))) > > (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-po= sition)))) > > (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, expec= ted): > >=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 > > >=20 >