14

I want to create a new frame that contains nothing but the mode-line. Especially not a file buffer.

Why do I need this? I use org-mode's clocking to time my work. Org-mode displays the timer for the current task I'm working on in the mode-line, and updates the timer in real-time. I use apps other than Emacs, so when I switch to them (e.g.. when using the browser or terminal) I still want to be able to look at the running timer. I thought I could create a new frame, but when I now click on the timer in the mode-line the .org file is getting opened in the new frame (which is already resized to show only mode-line) instead of jumping back to it in the first frame.

Here's how my mode-line looks (the blue bar) -- that is all I want on the new frame:

enter image description here

(Eventually I will have to figure out how to make the new frame appear always-on-top, but that is outside the scope of this question)

I use OS X if that is relevant.

  • 1
    Just a heads up, I'm working on some elisp and a macruby script that will display the org mode line information in the OSX menu bar. It's working for me but I'm going to try to wrap it up nicely. – Jordon Biondo Feb 02 '15 at 18:17
  • @JordonBiondo - excellent! your solution may turn out to be even better than what I'm doing here. looking forward to it. please keep me updated. – Sridhar Ratnakumar Feb 02 '15 at 22:17
  • You should retitle and rephrase your question, if you really feel that the answers you are saying "**Excellent!**" to respond to it. Because as far as I can tell they do *not* answer your request for a frame with "**nothing but a mode line**" - at all (and I doubt that any answer will). IOW, if you've relaxed your aim since the original formulation of your request, please consider updating the question accordingly. – Drew Feb 02 '15 at 23:43
  • I agree, after reading, it really seemed like OP had a specific problem, but was asking for only one solution, not the best solution. – Jordon Biondo Feb 03 '15 at 02:10
  • @Drew - Do you suggest any specific edits? PythonNut's original solution answers my original request. Note that I said "Especially not a file buffer.", and his solution - although creates an empty buffer - doesn't lead to file buffers appearing on the new frame. – Sridhar Ratnakumar Feb 03 '15 at 05:19
  • The title and question say that you want a **frame with only a mode line**. The solutions given produce an ordinary frame, albeit with an empty buffer and no menu-bar or tool-bar. They do not produce a frame that has only a mode line (for which I think the answer is probably: that's impossible - but I'm not certain). – Drew Feb 03 '15 at 18:37

4 Answers4

7

Extending Jorgen Schäfer's answer with Matthew Piziak's suggestion produces the following snippet:

(with-current-buffer (generate-new-buffer "*empty*")
  (make-frame '((minibuffer . nil)
                 (unsplittable . t)
                 (buffer-predicate . (lambda (x) nil))
                 (height . 2)
                 (left-fringe . 0)
                 (right-fringe . 0)
                 (tool-bar-lines . 0)
                 (menu-bar-lines . 0)))
  (set-window-dedicated-p
    (get-buffer-window (current-buffer) t) t))

As far as I can tell, this correctly locks the window to an empty buffer. Attempting to switch to a different buffer will open the buffer in an existing window in the parent frame.

PythonNut
  • 10,243
  • 2
  • 29
  • 75
  • Excellent, I've verified this to work. Any way to make the new frame inherit the font-size (and font-name) of the main frame? Also, can the redundant buffer-specific parts of the mode line -- `*empty* All L1 (Fundamental)` -- be removed? Here's how mine looks: http://i.imgur.com/iOLw57c.png – Sridhar Ratnakumar Feb 02 '15 at 22:05
  • @SridharRatnakumar Fortunately, stripping the extra mode-line info is trivial. I've amended my answer to include that. I'm not quite sure what you mean by preserving the font? Isn't the buffer empty? – PythonNut Feb 02 '15 at 23:54
  • I was referring to the font property of the text in the mode-line (not the empty buffer). – Sridhar Ratnakumar Feb 02 '15 at 23:58
  • ah, your later code cleared the mode-line of the main frame as well! If this is not possible, let's revert that change and I'll accept your answer (it satisfies the question). – Sridhar Ratnakumar Feb 02 '15 at 23:59
  • I just noticed that too. I've fixed it. The mode-line font doesn't change when I do it, so I'm not sure what's up. – PythonNut Feb 03 '15 at 00:21
  • best to revert to your original solution. with the new code, the modeline is completely empty even after clocking in org. – Sridhar Ratnakumar Feb 03 '15 at 05:18
  • @SridharRatnakumar alright, here you go. – PythonNut Feb 03 '15 at 05:23
5

This is the best I could come up with:

(with-current-buffer (generate-new-buffer "*empty*")
  (make-frame '((minibuffer . nil)
                (unsplittable . t)
                (buffer-predicate . (lambda (x) nil))
                (height . 2)
                (left-fringe . 0)
                (right-fringe . 0)
                (tool-bar-lines . 0)
                (menu-bar-lines . 0))))

I do not see a way to disable at least one window with one buffer there, but the one displayed using this snippet is not associated with any file. The buffer-predicate there prevents the frame from being chosen to display any (other) buffers, so if you can deal with one extra empty line, this should do it.

Jorgen Schäfer
  • 3,899
  • 2
  • 17
  • 19
  • It doesn't work as expected. Buffers are still being activated in the new frame. Here's an animated gif to illustrate: http://i.imgur.com/07Q3tcW.gifv – Sridhar Ratnakumar Jan 25 '15 at 13:38
  • 2
    Using [`display-buffer-alist`](http://www.gnu.org/software/emacs/manual/html_node/elisp/Choosing-Window.html) might be the solution to this. – Kaushal Modi Jan 25 '15 at 15:08
  • I do not know why org's use here does not adhere to the `buffer-predicate`. Using `display-buffer-alist` might be an idea indeed, but I do not know how to use it to prevent a specific frame from being used. – Jorgen Schäfer Jan 26 '15 at 12:54
  • Why is org to blame here? The new frame also displays buffers switched using `C-x b`. To me, the above code behaves exactly the same as `M-x new-frame` and manually resizing it. – Sridhar Ratnakumar Jan 27 '15 at 04:50
  • 2
    Could this be fixed with `set-window-dedicated-p`? – Matthew Piziak Jan 28 '15 at 16:19
  • @MatthewPiziak yes. I have a working code example. Should I post it, or send it to you? – PythonNut Feb 02 '15 at 19:27
  • @PythonNut - perhaps you can post it as an answer here. – Sridhar Ratnakumar Feb 02 '15 at 21:04
  • 1
    The `buffer-predicate` is, according to info, only used by the `other-buffer` function, i.e. it does not prevent other functions from displaying any buffer in the frame. – politza Feb 02 '15 at 22:15
3

Solution for displaying the org-clock information in the OSX menu bar

Here is an alternative solution to the problem you specified:

I use apps other than Emacs, so when I switch to them (e.g.. when using the browser or terminal) I still want to be able to look at the running timer.

You can use this to display the information from org-clock in the osx menubar which you should almost always be able to see.

https://github.com/jordonbiondo/osx-org-clock-menubar Available on MELPA

Note that this requires macruby.

What it looks like while clocked in.

enter image description here

Jordon Biondo
  • 12,332
  • 2
  • 41
  • 62
3

Yet another solution for org-clock in osx

A small box in status bar. It turns red when you didn't clock in.

illustration for red box, see github page

https://github.com/koddo/org-clock-statusbar-app

koddo
  • 233
  • 1
  • 7
  • 1
    I'm a bit late and do not answer the exact question, but I offer an alternative that would work for someone. – koddo Feb 05 '15 at 14:28