CCA EMACS Useful ELISP Example
Joaquim Martillo
martillo at mit-athena.ARPA
Sat Jan 12 01:53:05 AEST 1985
CCA EMACS does not backtab before a "}" in C-Mode. One can write a
function in elisp to do this. Here is one possibility
; Begin ELISP function definition
(defconstant close-brace (char-code #\}))
(defconstant tab (char-code #\tab))
(edefun |Close Squiggle Brace| (arg1 arg2 &optional op1 op2 op3)
(cond ((and (eql 'c (read-from-string (#f"& get major mode" #v"& current buffer")))
; The string equality function does not seem to work
(eql 1 #v"indent using tabs") ; For simplicity
(eql 8 #v"c indent")) ;Generalizing to more
;complex to C tabbing is
; not hard
(cond ((not (#f"& begin line")) ; Handles beginning of buffer problem
(#f"backward character" numarg 1)
(cond ((eql tab (char-code (emacs-get-char)))
; Seems to move point 1 char to the right
(#f"backward character" numarg 1)
(#f"delete character" noarg 0))
(t nil)))
(t nil)))
(t nil))
(emacs-insert-char #\}))
; That's the function
Unfortionately & bind local does not seem to work properly with changing
modes. Therefore I suggest binding this to "}" using a keyboard macro.
More information about the Comp.sources.unix
mailing list