[Top][All Lists]

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

Re: Single modeline for all buffers?

From: martin rudalics
Subject: Re: Single modeline for all buffers?
Date: Wed, 05 Feb 2014 18:46:48 +0100

> Can I have sth. like the following?
>      | [#]include <stdio.h>     | (defun add (x y) (+ x y)\|
>      | int main(int argc, char \| )                        |
>      | ** argv, char ** envp) { | (add 5 6) ;=> 11         |
>      -------------------------------------------------------
>      |-:-- hello.c  Top (1, 0)   (C/l Arev AC hl-p hl-s Abb|
>      -------------------------------------------------------
>      |                                                     |
>      -------------------------------------------------------

Not really.  This would require a major redesign of the involved
components.  If you have Emacs 24.4 you can try (better with Emacs -Q)
the proof of concept below (for fun only).

If you are really interested, you'd have to fill in two things:

(1) A mechanism that would allow this to work with multiple frames (that
    is, things like mode-line-buffer and mode-line-window would have to
    become frame parameters).  This is fairly easy.

(2) A mechanism to implement keybindings in the mode-line buffer.  This
    should be easy too but is likely tedious.  You would mostly have to
    replace occurrences of

      (with-selected-window (posn-window (event-start event))

    with something like

      (with-selected-window mode-line-really-selected-window

    where mode-line-really-selected-window would refer to the window the
    mode-line is currently talking about.


(defvar mode-line-buffer (get-buffer-create "mode-line"))

(defvar mode-line-window (display-buffer-in-side-window mode-line-buffer nil))

(defvar original-mode-line nil)
(make-variable-buffer-local 'original-mode-line)

(with-current-buffer mode-line-buffer
  (font-lock-mode -1)
  (setq mode-line-format nil))

(defun mode-line-buffer-list ()
   (lambda (window)
     (with-current-buffer (window-buffer window)
       (when mode-line-format
         (setq original-mode-line-format mode-line-format)
         (setq mode-line-format nil))))))

(defun mode-line-post-command ()
  (let ((format original-mode-line-format)
        (buffer (current-buffer))
        (window (selected-window)))
    (with-selected-window mode-line-window
      (insert (format-mode-line format 'mode-line window buffer))
      (let ((window-min-height 1)
            (window-resize-pixelwise t))
        (setq window-size-fixed nil)
        (set-window-start nil (point-min))
        (setq window-size-fixed t)))))

(with-selected-window mode-line-window
  (buffer-face-set 'mode-line)
  (setq default-frame-alist '((right-divider-width . 4) (bottom-divider-width . 
  (set-window-margins nil 0 0)
  (set-window-fringes nil 0 0)
  (set-window-scroll-bars nil 0)
  (setq cursor-type nil)
  (set-window-parameter nil 'no-other-window t)
  (set-window-dedicated-p nil t))

(add-hook 'post-command-hook 'mode-line-post-command)
(add-hook 'buffer-list-update-hook 'mode-line-buffer-list)

reply via email to

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