EMACS-DOCUMENT

=============>集思广益

宣示你的自由(禁止Emacs中的广告行为)

我使用Emacs的第一件事就是禁止显示它的启动画面. 方法也很简单,只需要 (setq inhibit-splash-screen t) 即可. 但是现在这已经不是Emacs侵犯你自由的唯一一个地方了. 若你仔细观察,会发现在echo area有一行小小的提示:

For information about GNU Emacs and the GNU system, type C-h C-a.

要禁用这行提示,会稍微麻烦一点. 该行消息来自于 startup-echo-area-message 函数,而该函数又被 display-startup-echo-area-message 函数所调用. 通过查看源代码 能够看出要想去掉该广告有多难:

(defun display-startup-echo-area-message ()
  (let ((resize-mini-windows t))
    (or noninteractive                  ;(input-pending-p) init-file-had-error
        ;; t if the init file says to inhibit the echo area startup message.
        (and inhibit-startup-echo-area-message
             user-init-file
             (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
                      (equal inhibit-startup-echo-area-message
                             (if (equal init-file-user "")
                                 (user-login-name)
                               init-file-user)))
                 ;; Wasn't set with custom; see if .emacs has a setq.
                 (condition-case nil
                     (with-temp-buffer
                       (insert-file-contents user-init-file)
                       (re-search-forward
                        (concat
                         "([ \t\n]*setq[ \t\n]+"
                         "inhibit-startup-echo-area-message[ \t\n]+"
                         (regexp-quote
                          (prin1-to-string
                           (if (equal init-file-user "")
                               (user-login-name)
                             init-file-user)))
                         "[ \t\n]*)")
                        nil t))
                   (error nil))))
        (message "%s" (startup-echo-area-message)))))

看起来,你要么在你的初始化文件中写上 (setq inhibit-startup-echo-area-message "<user>") 这么一句话(一定要写在 user-init-file 中,写在其他文件或编译了初始化文件或使用了其他的用户名都是无效的!),要么就重新定义 startup-echo-area-message 函数来显示其他内容. 你猜最后我选择了哪种方式 …

我十分赞同 变量 inhib0t-startup-echo-area-message 中注释中所说的:

;; FIXME? Why does this get such weirdly extreme treatment, when the
;; more important inhibit-startup-screen does not.
(defcustom inhibit-startup-echo-area-message nil
  "Non-nil inhibits the initial startup echo area message.
Setting this variable takes effect
only if you do it with the customization buffer
or if your init file contains a line of this form:
 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
If your init file is byte-compiled, use the following form
instead:
 (eval \\='(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
Thus, someone else using a copy of your init file will see the
startup message unless he personally acts to inhibit it."
  :type '(choice (const :tag "Don't inhibit")
                 (string :tag "Enter your user name, to inhibit"))
  :group 'initialization)