unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: Xue Fuqiao <xfq.free@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: About `name' in loadup.el
Date: Sun, 10 Mar 2013 12:19:20 +0530	[thread overview]
Message-ID: <874ngjagwf.fsf@gmail.com> (raw)
In-Reply-To: <20130310143815.79a2a26ee9ffc88b53cf08d5@gmail.com> (Xue Fuqiao's message of "Sun, 10 Mar 2013 14:38:15 +0800")

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	other threads:[~2013-03-10  6:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-10  6:38 About `name' in loadup.el Xue Fuqiao
2013-03-10  6:49 ` Jambunathan K [this message]
2013-03-10  7:07   ` Xue Fuqiao
2013-03-10 20:00     ` Andy Moreton
2013-03-10 22:37       ` Xue Fuqiao
  -- strict thread matches above, loose matches on Subject: below --
2013-03-10  0:11 Xue Fuqiao
2013-03-10  0:44 ` Pascal J. Bourguignon
2013-03-10  3:51 ` Eli Zaretskii
2013-03-10 11:27 ` Thien-Thi Nguyen
2013-03-10 13:02   ` Xue Fuqiao
2013-03-13 10:35     ` Thien-Thi Nguyen
2013-03-13 11:10       ` Xue Fuqiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874ngjagwf.fsf@gmail.com \
    --to=kjambunathan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=xfq.free@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).