Gnus development mailing list
 help / color / mirror / Atom feed
From: "Adam Sjøgren" <asjo@koldfront.dk>
To: ding@gnus.org
Subject: Re: Message-ID's secret
Date: Sat, 16 Nov 2019 16:16:22 +0100	[thread overview]
Message-ID: <87h833zwah.fsf@tullinup.koldfront.dk> (raw)
In-Reply-To: <yw.149.38wcdxf2u5.fsf@delta.birch.chromebook>

황병희 writes:

> Really i'm Gnus' fan so i'm wondering Gnus' message-id have some secret.

Secret?

> According my view:
> gnu/linux start with "87"
> darwin start with "m2"
> windows-nt start with "86" or "83"
>
> I saw the source code in message.el but still i do not
> understand. Somebody explain about that?

This is the function you want to understand:

  (defun message-unique-id ()
    ;; Don't use microseconds from (current-time), they may be unsupported.
    ;; Instead we use this randomly inited counter.
    (setq message-unique-id-char
          (% (1+ (or message-unique-id-char
                     (random (ash 1 20))))
             ;; (current-time) returns 16-bit ints,
             ;; and 2^16*25 just fits into 4 digits i base 36.
             (* 25 25)))
    (let ((tm (current-time)))
      (concat
       (if (or (eq system-type 'ms-dos)
               ;; message-number-base36 doesn't handle bigints.
               (floatp (user-uid)))
           (let ((user (downcase (user-login-name))))
             (while (string-match "[^a-z0-9_]" user)
               (aset user (match-beginning 0) ?_))
             user)
         (message-number-base36 (user-uid) -1))
       (message-number-base36 (+ (car tm)
                                 (ash (% message-unique-id-char 25) 16)) 4)
       (message-number-base36 (+ (nth 1 tm)
                                 (ash (/ message-unique-id-char 25) 16)) 4)
       ;; Append a given name, because while the generated ID is unique
       ;; to this newsreader, other newsreaders might otherwise generate
       ;; the same ID via another algorithm.
       ".fsf")))

One way to figure out what happens is to use the M-x edebug-defun
command on the function, and then calling it. You will then be able to
step through the function, seeing every return value along the way. Here
is the manual:

 · https://www.gnu.org/software/emacs/manual/html_node/eintr/edebug.html

It is quite handy!

E.g. the "87" you see is due to your uid, from the line:

         (message-number-base36 (user-uid) -1))


  Best regards,

    Adam

-- 
 "I wish *I* was a tiger!"                                     Adam Sjøgren
 "A common lament."                                       asjo@koldfront.dk
 




  parent reply	other threads:[~2019-11-16 15:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-16 14:56 황병희
2019-11-16 15:14 ` Andreas Schwab
2019-11-16 15:46   ` 황병희
2019-11-16 15:16 ` Adam Sjøgren [this message]
2019-11-17 15:28   ` 황병희
2019-11-17 16:40     ` Adam Sjøgren
2019-11-18 13:35       ` 황병희
2019-11-19  4:59       ` 황병희
2019-11-20  4:33         ` 황병희
2019-11-21 12:39           ` 황병희
2019-11-21 22:12             ` 황병희
2020-08-06  3:18               ` 황병희
2020-08-14  4:52                 ` 황병희
2020-09-09  3:06                   ` 황병희
2020-12-26  1:43                     ` Byung-Hee HWANG
2020-10-20 15:36       ` Zhiwei Chen

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

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

  git send-email \
    --in-reply-to=87h833zwah.fsf@tullinup.koldfront.dk \
    --to=asjo@koldfront.dk \
    --cc=ding@gnus.org \
    /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 NNTP newsgroup(s).