[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A true challenge for Emac and Elisp hackers - at Least I think so
From: |
Gian Uberto Lauri |
Subject: |
A true challenge for Emac and Elisp hackers - at Least I think so |
Date: |
Wed, 12 Oct 2005 14:49:00 +0200 |
>>>>> "S" == Sune <sune_ahlgren@hotmail.com> writes:
S> * If I hit RET with any shift-key being pressed simultaneously,
S> RET must behave as any normal RET would (basically a normal
S> linefeed with possible auto-indentation). This may seem backward
S> but I want almost every line in my sorce to be traceable.
S> * If I hit RET only, and the following applies:
S> - It is preceeded by a ';' (semicolon) AND the word 'return'
S> is not part of the current line or:
S> - It is preceeded by a '{' (curly bracket)
S> RET adds DBG after the ';' or the '{' with a space in between
S> like so:
S> ; DBG { DBG
S> respectively. After that (the same key stroke) , RET behaves
S> like a normal RET would (basically a normal linefeed with possible
S> auto-indentation).
S> I have to admit that this is so far out there (at least for me)
S> that I would need more or less a ready-to-go implementation just to
S> paste into .emacs.
Does this help ?
(defun unusual-return ()
(interactive)
(save-excursion)
(let ((here (point))
(previous-char (char-before)))
(beginning-of-line)
(cond ((string-match "DGB[ \\t]*$"
(buffer-substring (point) here))
(goto-char here)
(newline-and-indent))
((or (char-equal previous-char ?{)
(char-equal previous-char ?\;))
(goto-char here)
(insert " DBG"))
(t
(goto-char here)
(newline-and-indent)))))
You then add an hook to c-mode a little function that does the
following:
tests that the buffer name does end by .c
locally sets RET to the function above (or a better one, this is a
5 minutes game result)
locally sets S-RET, C-RET and M-RET to newline-and-indent
--
/\ ___
/___/\__|_|\_|__|___Gian Uberto Lauri_____________________
//--\ | | \| | Integralista GNUslamico
\/ e allevatore di bug da competizione
Re: A true challenge for Emac and Elisp hackers - at Least I think so, Pascal Bourguignon, 2005/10/12
RE: A true challenge for Emac and Elisp hackers - at Least I think so, Drew Adams, 2005/10/12
Re: A true challenge for Emac and Elisp hackers - at Least I think so, Thien-Thi Nguyen, 2005/10/12