help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I put display-time to the right of the mode line?


From: Emanuel Berg
Subject: Re: How can I put display-time to the right of the mode line?
Date: Wed, 11 Dec 2013 16:58:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Is there a way to have some information in the mode
> line, in my case the time showed by display-time, to be
> at all the way to the right of the mode line?

Yes, I found the mode line is configurable with the
below Elisp [last]. If you want context (and some more
defuns to do various things to the mode line), check
out the entire config file [1].

For a particular mode, you'll need something like this,
in combination with the rest.

;;;; shell / SHELL
(defun set-shell-mode-line ()
  "Mode line: Set the mode line for `shell' use."
  (set-variable '*mode-line-caption*                     "zsh"   t)
  (set-variable '*show-mode-line-caption*                t       t)
  (set-variable '*show-mode-line-modified*               nil     t)
  (set-variable '*show-default-directory*                nil     t)
  (set-variable '*show-mode-line-buffer-identification*  nil     t)
  (set-variable '*show-mode-line-modes*                  nil     t)
  (set-variable 'column-number-mode                      nil     t)
  (set-variable 'line-number-mode                        nil     t) )
(add-hook 'shell-mode-hook 'set-shell-mode-line)

If you can figure out how all that works, you are a
bright guy. What is dynamic and what is not, is all
intermixed at different layers. But if you do the work
of setting it up (mode by mode, if you want it) I can
guarantee it works, as I used it several years by
now. However, that doesn't say, there isn't a better
way to do it.

[1] http://user.it.uu.se/~embe8573/conf/.emacs-mode-line

;;; what to show
(defvar *show-mode-line-caption*)
(setq *show-mode-line-caption* nil)
(defvar *mode-line-caption*)
(defvar *show-mode-line-modified*)
(setq *show-mode-line-modified* t)
(defvar *show-mode-line-buffer-identification*)
(setq *show-mode-line-buffer-identification* t)
(defvar *show-mode-line-modes*)
(setq *show-mode-line-modes* nil)
(setq column-number-mode nil)
(setq line-number-mode nil)
(defvar *show-default-directory*)
(setq *show-default-directory* t)

(defun set-mode-line ()
  "Mode line: Show the mode line elements if the
respective global booleans are set."
  (setq-default mode-line-format
   `(" "
     (*show-mode-line-modified* mode-line-modified)
     (*show-mode-line-modified* " ")
     (*show-mode-line-caption* *mode-line-caption*)
     (*show-mode-line-caption* " ")
     (*show-default-directory* default-directory)
     (*show-mode-line-buffer-identification* mode-line-buffer-identification)
     (*show-mode-line-buffer-identification* " ")
     (line-number-mode   "[%l] ")
     (column-number-mode "{%c} ")
     (*show-mode-line-modes* mode-line-modes)
     )))
(set-mode-line)

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]