* About `name' in loadup.el @ 2013-03-10 0:11 Xue Fuqiao 2013-03-10 0:44 ` Pascal J. Bourguignon ` (2 more replies) 0 siblings, 3 replies; 12+ messages in thread From: Xue Fuqiao @ 2013-03-10 0:11 UTC (permalink / raw) To: help-gnu-emacs 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)) I'm confused here. What does this fragment of code do? And when will characters other than "-+_.a-zA-Z0-9" be in `emacs-version'? Can anybody help? Thanks. -- Best regards, Xue Fuqiao. http://www.emacswiki.org/emacs/XueFuqiao ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-10 0:11 About `name' in loadup.el 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 2 siblings, 0 replies; 12+ messages in thread From: Pascal J. Bourguignon @ 2013-03-10 0:44 UTC (permalink / raw) To: help-gnu-emacs 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)) > > I'm confused here. What does this fragment of code do? And when will > characters other than "-+_.a-zA-Z0-9" be in `emacs-version'? When you run Xemacs, or some other emacs: emacs-version --> "21.4 (patch 22) \"Instant Classic\" XEmacs Lucid" > Can anybody help? Probably. > Thanks. You're welcome. -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-10 0:11 About `name' in loadup.el 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 2 siblings, 0 replies; 12+ messages in thread From: Eli Zaretskii @ 2013-03-10 3:51 UTC (permalink / raw) To: help-gnu-emacs > Date: Sun, 10 Mar 2013 08:11:24 +0800 > From: Xue Fuqiao <xfq.free@gmail.com> > > 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)) > > I'm confused here. What does this fragment of code do? It creates a hard link emacs-XX.YY.ZZ -> emacs. > And when will characters other than "-+_.a-zA-Z0-9" be in > `emacs-version'? It's a 'while', not an 'if'. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-10 0:11 About `name' in loadup.el 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 2 siblings, 1 reply; 12+ messages in thread From: Thien-Thi Nguyen @ 2013-03-10 11:27 UTC (permalink / raw) To: Xue Fuqiao; +Cc: help-gnu-emacs [-- Attachment #1: Type: text/plain, Size: 952 bytes --] () Xue Fuqiao <xfq.free@gmail.com> () Sun, 10 Mar 2013 08:11:24 +0800 I'm confused here. [questions] Can anybody help? I think you can help yourself, and others to help you, if you explain how it is that you believe yourself to be confused. For example: I understand that [...] but it seems that the code does [...] This way, the answers can address the misunderstanding directly (if there is any -- perhaps you are not confused after all!), instead of stating (or pointing to) things that you might already know well enough. Why pay to rebuild the house when only the lightbulb needs replacement? Adopting this approach is beneficial in another way: You will no longer need to ask the somewhat pointless question "Can anybody help?". The answer to that question is always "yes". (Likewise, the answer to "Who can help?" must necessarily include "Xue Fuqiao". :-D) -- Thien-Thi Nguyen GPG key: 4C807502 [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-10 11:27 ` Thien-Thi Nguyen @ 2013-03-10 13:02 ` Xue Fuqiao 2013-03-13 10:35 ` Thien-Thi Nguyen 0 siblings, 1 reply; 12+ messages in thread From: Xue Fuqiao @ 2013-03-10 13:02 UTC (permalink / raw) To: Thien-Thi Nguyen; +Cc: help-gnu-emacs On Sun, 10 Mar 2013 12:27:37 +0100 Thien-Thi Nguyen <ttn@gnuvola.org> wrote: > () Xue Fuqiao <xfq.free@gmail.com> > () Sun, 10 Mar 2013 08:11:24 +0800 > > I'm confused here. > > [questions] > > Can anybody help? Thanks for your attention. This might have been a mode -- xue-fuqiao-ask-mode... > I think you can help yourself, and others to help you, if you explain > how it is that you believe yourself to be confused. That's true. Hasty-sounding questions get hasty answers, or none at all, I know that. People on these newsgroups are volunteers. They take time out of busy lives to answer questions, and at times they're overwhelmed with the questions. So I'm always finding a way to reduce questions, or to enhance the quality of questions. As I said in this thread, I usually do many things before asking a questions: http://lists.gnu.org/archive/html/help-gnu-emacs/2013-01/msg00076.html > For example: > > I understand that [...] but it seems that the code does [...] > > This way, the answers can address the misunderstanding directly (if > there is any -- perhaps you are not confused after all!), instead of > stating (or pointing to) things that you might already know well enough. > Why pay to rebuild the house when only the lightbulb needs replacement? Sometimes I will ask a stupid question; sorry for that. IRC often give the quickest response, but I want my question to be archived in order that I can easily check them later. And it can help many other people. To help other people, I can add some questions to the Emacs FAQ, since the Emacs FAQ is extremely crufty and hardly likely to answer any question frequently asked today. English is my native language, I am familiar with the technical terms (at least with most terms in Emacs), but many slang expressions and idioms are difficult for me. And sometimes I'll report a bug, that's a different issue. I'll not discuss it here now. If I ask a code problem, I'll try to provide a minimal test case, but it is not always be possible. > Adopting this approach is beneficial in another way: You will no longer > need to ask the somewhat pointless question "Can anybody help?". The > answer to that question is always "yes". (Likewise, the answer to "Who > can help?" must necessarily include "Xue Fuqiao". :-D) I won't close my request for help with semantically-null questions like “Can anyone help?” any more, because they are superfluous and annoying — like what you said. Answering one good question is like feeding a hungry person one meal, but teaching them (in this case, me) skills is showing them how to grow food for a lifetime. I really appreciate your answers with patience, and sorry for my poor English. -- Best regards, Xue Fuqiao. http://www.emacswiki.org/emacs/XueFuqiao ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-10 13:02 ` Xue Fuqiao @ 2013-03-13 10:35 ` Thien-Thi Nguyen 2013-03-13 11:10 ` Xue Fuqiao 0 siblings, 1 reply; 12+ messages in thread From: Thien-Thi Nguyen @ 2013-03-13 10:35 UTC (permalink / raw) To: Xue Fuqiao; +Cc: help-gnu-emacs [-- Attachment #1: Type: text/plain, Size: 1693 bytes --] () Xue Fuqiao <xfq.free@gmail.com> () Sun, 10 Mar 2013 21:02:49 +0800 As I said in this thread, I usually do many things before asking a questions: http://lists.gnu.org/archive/html/help-gnu-emacs/2013-01/msg00076.html One thing that you can add to that list is to try executing code (that you feel is safe), to see how it behaves in reality. If the snippet is small and relatively self-contained (as in this particular case), it can be fun to wrap it in a command and edebug it. For example, in *scratch*: (defun ttn-try () (interactive) (... some code ...)) (global-set-key [(meta f1)] 'ttn-try) Then: - Place point on the ‘defun’ and do ‘M-x edebug-defun RET’. - Invoke (via ‘M-f1’), step through (via ‘SPC’), eval (via ‘e’), etc. There is also ‘edebug-eval-top-level-form’, which is easier to work with (less preparation required). I use ‘edebug-defun’ out of habit, mostly. > Adopting this approach is beneficial in another way: You will no > longer need to ask the somewhat pointless question "Can anybody > help?". The answer to that question is always "yes". (Likewise, > the answer to "Who can help?" must necessarily include "Xue > Fuqiao". :-D) I won't close my request for help with semantically-null questions like “Can anyone help?” any more, because they are superfluous and annoying — like what you said. Well, the truth is i have a lot of practice being superfluous and annoying. You could say i'm an expert on this subject! :-D Anyway, Emacs is cool because you can study it also "from the inside". -- Thien-Thi Nguyen GPG key: 4C807502 [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-13 10:35 ` Thien-Thi Nguyen @ 2013-03-13 11:10 ` Xue Fuqiao 0 siblings, 0 replies; 12+ messages in thread From: Xue Fuqiao @ 2013-03-13 11:10 UTC (permalink / raw) To: Thien-Thi Nguyen; +Cc: help-gnu-emacs On Wed, 13 Mar 2013 11:35:31 +0100 Thien-Thi Nguyen <ttn@gnuvola.org> wrote: > () Xue Fuqiao <xfq.free@gmail.com> > () Sun, 10 Mar 2013 21:02:49 +0800 > As I said in this thread, I usually do many things before asking a > questions: > http://lists.gnu.org/archive/html/help-gnu-emacs/2013-01/msg00076.html > One thing that you can add to that list is to try executing code (that > you feel is safe), to see how it behaves in reality. If the snippet > is small and relatively self-contained (as in this particular case), > it can be fun to wrap it in a command and edebug it. That's true; and sometimes debugger-mode or GDB is more useful. -- Best regards, Xue Fuqiao. http://www.emacswiki.org/emacs/XueFuqiao ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el @ 2013-03-10 6:38 Xue Fuqiao 2013-03-10 6:49 ` Jambunathan K 0 siblings, 1 reply; 12+ messages in thread From: Xue Fuqiao @ 2013-03-10 6:38 UTC (permalink / raw) To: help-gnu-emacs > > 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"? -- Best regards, Xue Fuqiao. http://www.emacswiki.org/emacs/XueFuqiao ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-10 6:38 Xue Fuqiao @ 2013-03-10 6:49 ` Jambunathan K 2013-03-10 7:07 ` Xue Fuqiao 0 siblings, 1 reply; 12+ messages in thread From: Jambunathan K @ 2013-03-10 6:49 UTC (permalink / raw) To: Xue Fuqiao; +Cc: help-gnu-emacs 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'. -- ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-10 6:49 ` Jambunathan K @ 2013-03-10 7:07 ` Xue Fuqiao 2013-03-10 20:00 ` Andy Moreton 0 siblings, 1 reply; 12+ messages in thread From: Xue Fuqiao @ 2013-03-10 7:07 UTC (permalink / raw) To: Jambunathan K; +Cc: help-gnu-emacs On Sun, 10 Mar 2013 12:19:20 +0530 Jambunathan K <kjambunathan@gmail.com> wrote: > 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)) [...] > >> > 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"? [...] > So it is stripping stuff. I see. It makes the program more robust, isn't it? > I am reminded of `replace-regexp-in-string'. I am reminded of the `strip' function in GNU `make'. -- Best regards, Xue Fuqiao. http://www.emacswiki.org/emacs/XueFuqiao ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-10 7:07 ` Xue Fuqiao @ 2013-03-10 20:00 ` Andy Moreton 2013-03-10 22:37 ` Xue Fuqiao 0 siblings, 1 reply; 12+ messages in thread From: Andy Moreton @ 2013-03-10 20:00 UTC (permalink / raw) To: help-gnu-emacs On Sun 10 Mar 2013, Xue Fuqiao wrote: > On Sun, 10 Mar 2013 12:19:20 +0530 > Jambunathan K <kjambunathan@gmail.com> wrote: > >> 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)) > [...] >> >> > 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"? > > [...] > >> So it is stripping stuff. > > I see. It makes the program more robust, isn't it? The name is used to create a hardlink, so to avoid problems it should only contain characters that are allowed in portable filenames. This means removing the non-portable characters and replacing them with something that all filesystems should be able to cope with. AndyM ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: About `name' in loadup.el 2013-03-10 20:00 ` Andy Moreton @ 2013-03-10 22:37 ` Xue Fuqiao 0 siblings, 0 replies; 12+ messages in thread From: Xue Fuqiao @ 2013-03-10 22:37 UTC (permalink / raw) To: Andy Moreton; +Cc: help-gnu-emacs On Sun, 10 Mar 2013 20:00:38 +0000 Andy Moreton <andrewjmoreton@gmail.com> wrote: > >> >> > 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)) [...] > >> >> > And when will characters other than "-+_.a-zA-Z0-9" be in > >> >> > `emacs-version'? [...] > >> So it is stripping stuff. > > I see. It makes the program more robust, isn't it? > The name is used to create a hardlink, so to avoid problems it should > only contain characters that are allowed in portable filenames. This > means removing the non-portable characters and replacing them with > something that all filesystems should be able to cope with. Thanks. -- Best regards, Xue Fuqiao. http://www.emacswiki.org/emacs/XueFuqiao ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-03-13 11:10 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-03-10 0:11 About `name' in loadup.el 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 -- strict thread matches above, loose matches on Subject: below -- 2013-03-10 6:38 Xue Fuqiao 2013-03-10 6:49 ` Jambunathan K 2013-03-10 7:07 ` Xue Fuqiao 2013-03-10 20:00 ` Andy Moreton 2013-03-10 22:37 ` Xue Fuqiao
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).