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

Re : Re: sed ignorer une occurence



Le jeudi 1 juin 2023 à 20:54, Michel Verdier <mv524@free.fr> a écrit :

> 
> Autant pour moi, faut toujours regarder les Messages :)
> Là ça devrait marcher pour de vrai.
> 
> (defun ConvertRet ()
> "Convertit un retour à la ligne."
> (interactive)
> (let (
> (p1 (region-beginning))
> (p2 (region-end)))
> (save-restriction
> (narrow-to-region p1 p2)
> (goto-char (point-min))
> (while (re-search-forward "-\\\n" nil t)
> (replace-match "" nil t))
> (goto-char (point-min))
> (while (re-search-forward "\\([^.]\\)\\\n" nil t)
> (replace-match (concat (match-string 1) " ") nil t))
> )))
> 


Un tout grand merci... :-)


A certains endroits ça mets deux espaces, je vais chercher pourquoi...
Mais en attendant de comprendre, je retourne au début et repasse une fois pour les virer et c'est bon ! ;-)


(defun ConvertRet ()
  "Convertit les retours à la ligne."
  (interactive)
  (let (
	(p1 (region-beginning))
	(p2 (region-end)))
    (save-restriction
      (narrow-to-region p1 p2)
      (goto-char (point-min))
      (while (re-search-forward "-\\\n" nil t)
	(replace-match "" nil t))
      (goto-char (point-min))
      (while (re-search-forward "\\([^.]\\)\\\n" nil t)
	(replace-match (concat (match-string 1) " ") nil t))
      (goto-char (point-min))
      (while (re-search-forward "  " nil t)
	(replace-match " " nil t))
      
      )))


Avec gratitude,

--
Benoît


Reply to: