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

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

Re: suppress terminating return by shell-command-on-region


From: Pascal J. Bourguignon
Subject: Re: suppress terminating return by shell-command-on-region
Date: Wed, 08 Dec 2010 15:25:50 -0000
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/23.2 (gnu/linux)

Cecil Westerhof <Cecil@decebal.nl> writes:

> Op vrijdag 20 aug 2010 17:53 CEST schreef Pascal J. Bourguignon:
>
>> Cecil Westerhof <Cecil@decebal.nl> writes:
>>
>>> I needed to reverse some text in a buffer. For this I used:
>>> C-u M-| rev
>>>
>>> This works, except that there is put a return after the replaced
>>> region. Is it possible to suppress this return? It is not a biggy, I
>>> can remove it, but it would be nice if this was not necessary.
>>
>> Instead you could use M-x reverse-lines RET
>
> My Emacs does not know this function.

Oops, sorry, it's in http://tinyurl.com/pjb-utilities

(defun reverse-lines (start end)
  "Reverse the order of the characters in each lines in the region."
  (interactive "r")
  (let* ((text)(lines)(first))
    (setq text (buffer-substring-no-properties start end))
    (setq lines  (split-string text "[\n]"))
    (setq first lines)
    (while lines
      (if (< 0 (length (car lines)))
        (setcar lines (apply 'string (reverse (string-to-list (car lines))))))
      (setq lines (cdr lines)))
    (delete-region  start end)
    (insert (unsplit-string first "\n"))))

;; unsplit-string is in pjb-strings, get the whole sources...


>> (there's also a reverse-region).
>
> That does not what I want. It changes lines, but I want to change
> characters. For example from:
>     Some before text. Decebal Computing Some after text.
> to:
>     Some before text. gnitupmoC labeceD Some after text.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


reply via email to

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