help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining existence of text following point


From: Jean Louis
Subject: Re: Determining existence of text following point
Date: Wed, 19 May 2021 01:17:01 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* michael-franzese@gmx.com <michael-franzese@gmx.com> [2021-05-18 23:52]:
> For instance, if the text in a commented string as follows, I will go ahead 
> with
> the insertion.
> 
(defun my-insert-on-empty-end-of-line (s)
  (let ((line-cut (buffer-substring-no-properties (point) (line-end-position))))
    (when (or (not (string-match "[^[:blank:]]" line-cut)) (eolp))
      (insert s))))

(defun my-insert-on-empty-end-of-line (s)
  (let ((line-cut (buffer-substring-no-properties (point) (line-end-position))))
    (when (or (not (string-match "[^+[:blank:];-]" line-cut)) (eolp))
      (insert s))))

(defun my-insert ()
  (interactive)
  (my-insert-on-empty-end-of-line "Hello"))

(local-set-key (kbd "<f5>") 'my-insert)

Line with blanks, works:
;;          Hello                              

Line with something else but our series of chars (does not work, expected):

;;       █               abc

Line with fancy stuff that we wish to include (works):

;; ;;;;;;;;;;;;;;;;Hello;;;;;;;;;;;;;;;;;;;;;;
;; +++++++++++++++++++++Hello+++++++++++++
;; -------------------------Hello------Hello

Weird other lines (it does not work, as it is so expected):

;; 𝓒𝓾𝓻𝓼𝓸𝓻 𝓲𝓼 𝓱𝓮𝓻𝓮: █  𝓫𝓾𝓽 𝓲𝓼 𝓷𝓸𝓽 𝔀𝓸𝓻𝓴𝓲𝓷𝓰, 𝐄𝐗𝐏𝐄𝐂𝐓𝐄𝐃!


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]