[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)
       (let ((res (funcall action (car lst))))
         (if (null res)
             (eassist-do-for-first-suitable (cdr lst) action)

you can replace this w/ a `while' loop.  think about a cool drink on a
hot day (

   (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)
          (if (null (eassist-do-for-first-suitable
                     (cdr i)
              (message "..."))

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)

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
             (lambda (ch)
               (let ((up (upcase ch)) (down (downcase ch)))
                  ((= 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?


reply via email to

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