13

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 2 '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 2 '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 2 '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 3 '15 at 2: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 3 '15 at 5:19
7
+50

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.

  • 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: i.imgur.com/iOLw57c.png – Sridhar Ratnakumar Feb 2 '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 2 '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 2 '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 2 '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 3 '15 at 0:21
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.

  • It doesn't work as expected. Buffers are still being activated in the new frame. Here's an animated gif to illustrate: i.imgur.com/07Q3tcW.gifv – Sridhar Ratnakumar Jan 25 '15 at 13:38
  • 2
    Using display-buffer-alist 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
  • 2
    Could this be fixed with set-window-dedicated-p? – Matthew Piziak Jan 28 '15 at 16:19
  • 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 2 '15 at 22:15
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

  • 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 5 '15 at 14:28
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

  • 1
    A simple implementation that does not rely on macruby can be done with emacsclient -e "(org-clock-get-clocked-time)" and bitbar: getbitbar.com – mankoff Jul 8 '16 at 21:01
  • That's awesome you should write up a solution! – Jordon Biondo Jul 9 '16 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.