Function: mh-alias-local-users

mh-alias-local-users is a byte-compiled function defined in mh-alias.el.gz.

Signature

(mh-alias-local-users)

Documentation

Return an alist of local users from /etc/passwd.

Exclude all aliases already in mh-alias-alist from "ali"

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-alias.el.gz
(defun mh-alias-local-users ()
  "Return an alist of local users from /etc/passwd.
Exclude all aliases already in `mh-alias-alist' from \"ali\""
  (let (passwd-alist)
    (with-current-buffer (get-buffer-create mh-temp-buffer)
      (erase-buffer)
      (cond
       ((eq mh-alias-local-users t)
        (if (file-readable-p "/etc/passwd")
            (insert-file-contents "/etc/passwd")))
       ((stringp mh-alias-local-users)
        (insert mh-alias-local-users "\n")
        (shell-command-on-region (point-min) (point-max) mh-alias-local-users t t)
        (goto-char (point-min))))
      (while  (< (point) (point-max))
        (cond
         ((looking-at "\\([^:]*\\):[^:]*:\\([^:]*\\):[^:]*:\\([^:]*\\):")
          (when (> (string-to-number (match-string 2)) 200)
            (let* ((username (match-string 1))
                   (gecos-name (match-string 3))
                   (realname (mh-alias-gecos-name
                              gecos-name username
                              mh-alias-passwd-gecos-comma-separator-flag))
                   (alias-name (if mh-alias-local-users-prefix
                                   (concat mh-alias-local-users-prefix
                                           (mh-alias-suggest-alias realname t))
                                 username))
                   (alias-translation
                    (if (string-equal username realname)
                        (concat "<" username ">")
                      (concat realname " <" username ">"))))
              (when (not (assoc-string alias-name mh-alias-alist t))
                (setq passwd-alist (cons (list alias-name alias-translation)
                                         passwd-alist)))))))
        (forward-line 1)))
    passwd-alist))