* Toggle a character between "T" and "F"
@ 2005-03-11 18:10 Scott Waichler
2005-03-11 18:33 ` Denis Bueno
2005-03-11 18:49 ` Reiner Steib
0 siblings, 2 replies; 3+ messages in thread
From: Scott Waichler @ 2005-03-11 18:10 UTC (permalink / raw)
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?
Thanks,
Scott Waichler
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Toggle a character between "T" and "F"
2005-03-11 18:10 Toggle a character between "T" and "F" Scott Waichler
@ 2005-03-11 18:33 ` Denis Bueno
2005-03-11 18:49 ` Reiner Steib
1 sibling, 0 replies; 3+ messages in thread
From: Denis Bueno @ 2005-03-11 18:33 UTC (permalink / raw)
Cc: help-gnu-emacs
On 11 Mar 2005 10:10:44 -0800, Scott Waichler <scott.waichler@pnl.gov> 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?
Possibly a kludge, but:
(defun toggle-t-r ()
(interactive)
(case (char-after)
(?F (delete-char 1)
(insert "T")
(backward-char 1))
(?T (delete-char 1)
(insert "F")
(backward-char 1))))
--
Denis Bueno
PGP: http://pgp.mit.edu:11371/pks/lookup?search=0xA1B51B4B&op=index
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Toggle a character between "T" and "F"
2005-03-11 18:10 Toggle a character between "T" and "F" Scott Waichler
2005-03-11 18:33 ` Denis Bueno
@ 2005-03-11 18:49 ` Reiner Steib
1 sibling, 0 replies; 3+ messages in thread
From: Reiner Steib @ 2005-03-11 18:49 UTC (permalink / raw)
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-03-11 18:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-11 18:10 Toggle a character between "T" and "F" Scott Waichler
2005-03-11 18:33 ` Denis Bueno
2005-03-11 18:49 ` Reiner Steib
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).