0

I'm trying to have my mode-line to display a "(modified)" string instead of the * mark. To do that, I make a test with buffer-modified-p but this seems to be always true for "special" buffers as well (such as for example completion list or org agenda). What would be the proper way to do the test (i.e. files that have been modified by me) ? Here is the relevant part of my code: '(:eval (if (buffer-modified-p) "%b (modified)" "%b"))

Solution:

'(:eval (if (and (or buffer-file-name
                    (string= (buffer-name) "*scracth*"))
                 (buffer-modified-p))
            "%b (modified)" "%b"))
  • 1
    Perhaps, you want (and buffer-file-name (buffer-modified-p)) as test? – Tobias May 6 at 9:05
  • Yes, that seems to do the trick. – Nicolas Rougier May 6 at 9:08
  • 1
    That depends what you want with the scratch buffer. It is (normally) not associated with a file. So do you want to have the modification notification there? – Tobias May 6 at 9:16
  • 1
    Yes, or (derived-mode-p 'lisp-interaction-mode) if you want to allow multiple scratch buffers. – Tobias May 6 at 9:24
  • 1
    (buffer-name) should work. – Tobias May 6 at 9:35

Your Answer

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

Browse other questions tagged or ask your own question.