[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EmacsAssist
From: |
Thien-Thi Nguyen |
Subject: |
Re: EmacsAssist |
Date: |
Tue, 28 Mar 2006 22:30:06 -0500 |
From: "Anton V. Belyaev" <address@hidden>
Date: 27 Mar 2006 10:15:20 -0800
(defun eassist-string-last (string n)
(substring string (- (length string) n)))
you can either replace callers of `(eassist-string-last STR N)'
with `(substring STR -N)', or use that in its definition.
;; Funcalls action until it is not nil.
;; Returns result of the last action.
(defun eassist-do-for-first-suitable (lst action)
(if (null lst)
nil
(let ((res (funcall action (car lst))))
(if (null res)
(eassist-do-for-first-suitable (cdr lst) action)
res))))
you can replace this w/ a `while' loop. think about a cool drink on a
hot day (http://www.glug.org/people/ttn/software/elisp-tutorial/).
(setq eassist-header-switches '(
("h" . ("cpp" "cc" "c"))
("hpp" . ("cpp"))
("cpp" . ("h" "hpp"))
("c" . ("h"))
("cc" . ("h" "hpp"))
))
if you use `defvar' instead of `setq', you can add documentation.
(lambda (i)
(if (string= (car i) ext)
(progn
(if (null (eassist-do-for-first-suitable
(cdr i)
'eassist-try-h-cpp))
(message "..."))
ext)
nil))
you can replace nested `if' expressions (and `progn') w/ `cond'.
i cut out the rest of the function, which flayed my poor 80x25 display.
(defun eassist-find-if-exist (file)
(if (file-exists-p file)
(progn (find-file file) file)
nil))
you can use `(when CONDITION THEN)' for `(if CONFITION THEN nil)'.
( t (format (format "%%%ds %%%ds
IMHO, the whitespace looks nicer on the other side of the `t'.
(defun eassist-case-insensitive-regexp (reg)
(apply 'string
(mapcan
(lambda (ch)
(let ((up (upcase ch)) (down (downcase ch)))
(cond
((= up down) (list ch))
(t (list ?\[ up down ?\])))))
(string-to-list reg))))
another approach is to bind `case-fold-search' dynamically to match
whichever policy is to be implemented. is there some CEDET-related
recommendation against that?
thi
- EmacsAssist, Anton V. Belyaev, 2006/03/27
- Re: EmacsAssist, Klaus Berndl, 2006/03/28
- Re: EmacsAssist,
Thien-Thi Nguyen <=
- Message not available