chopping a string in emacs lisp

chopping a string in emacs lisp

Post by Kai Gro?joha » Fri, 11 Jul 2003 16:51:33




>     chop    Chops off the last character of a string and returns the
>             character chopped....

(setq x (substring x 0 -1))

Maybe -2 instead of -1, I'm not sure.
--
~/.signature

 
 
 

1. Lisp-mode, font-lock strings at position 3 depth 1 as strings

lisp/font-lock.el says:

(defun font-lock-fontify-syntactically-region (start end &optional loudly)
[...]
    (let ((lisp-like (font-lock-lisp-like major-mode)))
      (syntactically-sectionize
       #'(lambda (s e context depth)
           (let (face)
             (cond ((eq context 'string)
                    (setq face
                          ;; #### It would be nice if we handled
                          ;; Python and other non-Lisp languages with
                          ;; docstrings correctly.
                          (if (and lisp-like (= depth 1))
                              ;; really we should only use this if
                              ;;  in position 3 depth 1, but that's
                              ;;  too expensive to compute.
                              'font-lock-doc-string-face
                            'font-lock-string-face)))
[...]

As the comment indicates, this does the wrong thing for forms like:
(defparameter *motd* "Howdy" "String used to greet user."), as "Howdy"
is fontified as a docstring.

If I am willing to wait for the computation of position 3 depth 1, in
order to make a correct choice between 'font-lock-string-face and
'font-lock-doc-string-face, how should I go about setting up the
behaviour I want?  The relevant major modes are common-lisp-mode and
emacs-lisp-mode.
--
chr

2. Poor Audio:

3. emacs lisp: regexps on string variables

4. RFD: sci.engr.semiconductors

5. Emacs-lisp question: prompt strings for interactive

6. RTX51 TINY LIB USING IN A ASSEMBLER SOURCE.

7. Adding C-code plug-ins to Emacs?

8. axes objects on .fig files

9. EMACS/AUCTEX and dtx/ins file types

10. Adding C-code plug-ins to Emacs?

11. Emacs Manual printing out with chopped page numbers

12. how to insert a comment string with a little lisp macro?

13. dtx and ins in xemacs