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

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

Re: Toggle a character between "T" and "F"


From: Reiner Steib
Subject: Re: Toggle a character between "T" and "F"
Date: Fri, 11 Mar 2005 19:49:36 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

On Fri, Mar 11 2005, Scott Waichler wrote:

> I am looking for a way to toggle the character under the cursor.  When
> the character is "T", I'd like to hit a keystroke and change it to "F",
> and vice versa.  I use these characters to set logical values in R
> programming.  Can anyone tell me the lisp coded needed for this?

Maybe like this...

(defun rs-toggle-T-and-F ()
  "Toggle the characters `T' nor `F' at point."
  (interactive)
  (let ((case-fold-search nil))
    (cond ((looking-at "T")
           (delete-char 1)
           (insert "F"))
          ((looking-at "F")
           (delete-char 1)
           (insert "T"))
          (t (message "Neither `T' nor `F' at point")))))

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/


reply via email to

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