help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About `name' in loadup.el


From: Jambunathan K
Subject: Re: About `name' in loadup.el
Date: Sun, 10 Mar 2013 12:19:20 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Xue Fuqiao <xfq.free@gmail.com> writes:

>> > In lisp/loadup.el:
>> > 
>> >   (let ((name (concat "emacs-" emacs-version)))
>> >     (while (string-match "[^-+_.a-zA-Z0-9]+" name)
>> >       (setq name (concat (downcase (substring name 0 (match-beginning 0)))
>> >                   "-"
>> >                   (substring name (match-end 0)))))
>> >     (message "Adding name %s" name)
>> >     (add-name-to-file "emacs" name t))
>> > 
>> > What does this fragment of code do?
>
>> It creates a hard link emacs-XX.YY.ZZ -> emacs.
>
> Thanks.
>
>> > And when will characters other than "-+_.a-zA-Z0-9" be in
>> > `emacs-version'?
>> 
>> It's a 'while', not an 'if'.
>
> Can you explain it more detailed?  Do you mean `emacs-version' won't
> contain "-+_.a-zA-Z0-9"?

It replaces a train of non-digits and english alphabets with `-'.  

So it is stripping stuff.  

Try this, I have added an extra var `emacs-version' in the loop, so C-x
C-e ing would give you

    (let* ((emacs-version "abcµ©1abc")
           (name (concat "emacs-" emacs-version)))
      (while (string-match "[^-+_.a-zA-Z0-9]+" name)
        (setq name (concat (downcase (substring name 0 (match-beginning 0)))
                           "-"
                           (substring name (match-end 0)))))
      (message "Adding name %s" name))

this
     => "Adding name emacs-abc-1abc"

I am reminded of `replace-regexp-in-string'.

-- 



reply via email to

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