Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an easy revert function #66

Open
MatthewDarling opened this issue Mar 13, 2014 · 2 comments
Open

Provide an easy revert function #66

MatthewDarling opened this issue Mar 13, 2014 · 2 comments

Comments

@MatthewDarling
Copy link

I'm testing out smart-mode-line to see if I like it better than Powerline, and one thing I really like about milkypostman's Powerline is that there's a great revert function.

However, smart-mode-line doesn't seem to have anything equivalent. I tried evaluating (copy-face 'sml/active-backup 'mode-line), but all that did was change the colour scheme. I'm sure there's some way to get the default back, but you'd probably know better than I would.

I'm sure it never occurred to you that someone would disable your amazing package, but it could be a useful feature for unconvinced new users :)

@Malabarba
Copy link
Owner

Ah... :-)
Back in the early days, when sml would shamelessly replace the entire mode-line, there was a revert function. The sml/active-backup (and similar) variable is a vestige of that.

Nowadays sml is much more mindful of not changing the structure of the mode-line-format variable (this way we don't break other packages that might edit this variable as well), so the revert feature pretty much stopped working.

I'll try to hack something quick that you can use.

@Malabarba
Copy link
Owner

Ok, it's not pretty, but here's what you can do to revert it (for now, I'll probably add a proper revert function over the weekend).

Just evaluate the following code (or put it inside a function).

(disable-theme 'smart-mode-line)
(copy-face 'sml/inactive-backup 'mode-line-inactive)
(copy-face 'sml/active-backup 'mode-line)
(ad-deactivate 'vc-mode-line)
(setq-default mode-line-format (eval (car (get 'mode-line-format 'standard-value))))
(setq-default
 mode-line-front-space  '(:eval (if (display-graphic-p) " " "-"))
                        mode-line-mule-info 
                        `(""
                          (current-input-method
                           (:propertize ("" current-input-method-title)
                                        help-echo (concat
                                                   ,(purecopy "Current input method: ")
                                                   current-input-method
                                                   ,(purecopy "\n\
mouse-2: Disable input method\n\
mouse-3: Describe current input method"))
                                        local-map ,mode-line-input-method-map
                                        mouse-face mode-line-highlight))
                          ,(propertize
                            "%z"
                            'help-echo 'mode-line-mule-info-help-echo
                            'mouse-face 'mode-line-highlight
                            'local-map mode-line-coding-system-map)
                          (:eval (mode-line-eol-desc)))
                        mode-line-client 
                        `(""
                          (:propertize ("" (:eval (if (frame-parameter nil 'client) "@" "")))
                                       help-echo ,(purecopy "emacsclient frame")))
                        mode-line-modified 
                        (list (propertize
                               "%1*"
                               'help-echo 'mode-line-read-only-help-echo
                               'local-map (purecopy (make-mode-line-mouse-map
                                                     'mouse-1
                                                     #'mode-line-toggle-read-only))
                               'mouse-face 'mode-line-highlight)
                              (propertize
                               "%1+"
                               'help-echo 'mode-line-modified-help-echo
                               'local-map (purecopy (make-mode-line-mouse-map
                                                     'mouse-1 #'mode-line-toggle-modified))
                               'mouse-face 'mode-line-highlight))
                        mode-line-remote 
                        (list (propertize
                               "%1@"
                               'mouse-face 'mode-line-highlight
                               'help-echo (purecopy (lambda (window _object _point)
                                                      (format "%s"
                                                              (with-selected-window window
                                                                (concat
                                                                 (if (file-remote-p default-directory)
                                                                     "Current directory is remote: "
                                                                   "Current directory is local: ")
                                                                 default-directory)))))))
                        mode-line-frame-identification  '(:eval (mode-line-frame-control))
                        mode-line-buffer-identification 
                        (propertized-buffer-identification "%12b")
                        mode-line-position 
                        `((-3 ,(propertize
                                "%p"
                                'local-map mode-line-column-line-number-mode-map
                                'mouse-face 'mode-line-highlight
                                ;; XXX needs better description
                                'help-echo "Size indication mode\n\
mouse-1: Display Line and Column Mode Menu"))
                          (size-indication-mode
                           (8 ,(propertize
                                " of %I"
                                'local-map mode-line-column-line-number-mode-map
                                'mouse-face 'mode-line-highlight
                                ;; XXX needs better description
                                'help-echo "Size indication mode\n\
mouse-1: Display Line and Column Mode Menu")))
                          (line-number-mode
                           ((column-number-mode
                             (10 ,(propertize
                                   " (%l,%c)"
                                   'local-map mode-line-column-line-number-mode-map
                                   'mouse-face 'mode-line-highlight
                                   'help-echo "Line number and Column number\n\
mouse-1: Display Line and Column Mode Menu"))
                             (6 ,(propertize
                                  " L%l"
                                  'local-map mode-line-column-line-number-mode-map
                                  'mouse-face 'mode-line-highlight
                                  'help-echo "Line Number\n\
mouse-1: Display Line and Column Mode Menu"))))
                           ((column-number-mode
                             (5 ,(propertize
                                  " C%c"
                                  'local-map mode-line-column-line-number-mode-map
                                  'mouse-face 'mode-line-highlight
                                  'help-echo "Column number\n\
mouse-1: Display Line and Column Mode Menu"))))))
                        mode-line-modes 
                        (let ((recursive-edit-help-echo "Recursive edit, type C-M-c to get out"))
                          (list (propertize "%[" 'help-echo recursive-edit-help-echo)
                                "("
                                `(:propertize ("" mode-name)
                                              help-echo "Major mode\n\
mouse-1: Display major mode menu\n\
mouse-2: Show help for major mode\n\
mouse-3: Toggle minor modes"
                                              mouse-face mode-line-highlight
                                              local-map ,mode-line-major-mode-keymap)
                                '("" mode-line-process)
                                `(:propertize ("" minor-mode-alist)
                                              mouse-face mode-line-highlight
                                              help-echo "Minor mode\n\
mouse-1: Display minor mode menu\n\
mouse-2: Show help for minor mode\n\
mouse-3: Toggle minor modes"
                                              local-map ,mode-line-minor-mode-keymap)
                                (propertize "%n" 'help-echo "mouse-2: Remove narrowing from buffer"
                                            'mouse-face 'mode-line-highlight
                                            'local-map (make-mode-line-mouse-map
                                                        'mouse-2 #'mode-line-widen))
                                ")"
                                (propertize "%]" 'help-echo recursive-edit-help-echo)
                                " "))
                        mode-line-misc-info 
                        '((which-func-mode ("" which-func-format " "))
                          (global-mode-string ("" global-mode-string " ")))
                        mode-line-end-spaces  '(:eval (unless (display-graphic-p) "-%-")))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants