Commits

Anonymous committed 1690f8c

Update

  • Participants
  • Parent commits 03344d1

Comments (0)

Files changed (10)

vendor/smex/smex.el

-;;; smex.el --- M-x interface with Ido-style fuzzy matching.
-
-;; Copyright (C) 2009-2012 Cornelius Mika
-;;
-;; Author: Cornelius Mika <cornelius.mika@gmail.com>
-;; URL: http://github.com/nonsequitur/smex/
-;; Version: 2.0
-;; Keywords: convenience, usability
-
-;; This file is not part of GNU Emacs.
-
-;;; License:
-
-;; Licensed under the same terms as Emacs.
-
-;;; Commentary:
-
-;; Quick start:
-;; run (smex-initialize)
-;;
-;; Bind the following commands:
-;; smex, smex-major-mode-commands
-;;
-;; For a detailed introduction see:
-;; http://github.com/nonsequitur/smex/blob/master/README.markdown
-
-;;; Code:
-
-(require 'ido)
-
-(defgroup smex nil
-  "M-x interface with Ido-style fuzzy matching and ranking heuristics."
-  :group 'extensions
-  :group 'convenience
-  :link '(emacs-library-link :tag "Lisp File" "smex.el"))
-
-(defcustom smex-auto-update t
-  "If non-nil, `Smex' checks for new commands each time it is run.
-Turn it off for minor speed improvements on older systems."
-  :type 'boolean
-  :group 'smex)
-
-(defcustom smex-save-file "~/.smex-items"
-  "File in which the smex state is saved between Emacs sessions.
-Variables stored are: `smex-data', `smex-history'.
-Must be set before initializing Smex."
-  :type 'string
-  :group 'smex)
-
-(defcustom smex-history-length 7
-  "Determines on how many recently executed commands
-Smex should keep a record.
-Must be set before initializing Smex."
-  :type 'integer
-  :group 'smex)
-
-(defcustom smex-prompt-string "M-x "
-  "String to display in the Smex prompt."
-  :type 'string
-  :group 'smex)
-
-(defcustom smex-key-advice-ignore-menu-bar nil
-  "If non-nil, `smex-key-advice' ignores `menu-bar' bindings"
-  :type 'boolean
-  :group 'smex)
-
-(defcustom smex-flex-matching t
-  "Enables Ido flex matching. On by default.
-Set this to nil to disable fuzzy matching."
-  :type 'boolean
-  :group 'smex)
-
-(defvar smex-initialized-p nil)
-(defvar smex-cache)
-(defvar smex-ido-cache)
-(defvar smex-data)
-(defvar smex-history)
-(defvar smex-command-count 0)
-(defvar smex-custom-action nil)
-
-;;--------------------------------------------------------------------------------
-;; Smex Interface
-
-;;;###autoload
-(defun smex ()
-  (interactive)
-  (unless smex-initialized-p
-    (smex-initialize))
-  (if (smex-already-running)
-      (smex-update-and-rerun)
-    (and smex-auto-update
-         (smex-detect-new-commands)
-         (smex-update))
-    (smex-read-and-run smex-ido-cache)))
-
-(defsubst smex-already-running ()
-  (and (boundp 'ido-choice-list) (eql ido-choice-list smex-ido-cache)))
-
-(defsubst smex-update-and-rerun ()
-  (smex-do-with-selected-item
-   (lambda (ignore) (smex-update) (smex-read-and-run smex-ido-cache ido-text))))
-
-(defun smex-read-and-run (commands &optional initial-input)
-  (let ((chosen-item (intern (smex-completing-read commands initial-input))))
-    (if smex-custom-action
-        (let ((action smex-custom-action))
-          (setq smex-custom-action nil)
-          (funcall action chosen-item))
-      (unwind-protect
-          (progn (setq prefix-arg current-prefix-arg)
-                 (setq this-command chosen-item)
-                 (command-execute chosen-item 'record))
-        (smex-rank chosen-item)
-        (smex-show-key-advice chosen-item)
-        ;; Todo: Is there a better way to manipulate 'last-repeatable-command'
-        ;; from the inside of an interactively called function?
-        (run-at-time 0.01 nil (lambda (cmd) (setq last-repeatable-command cmd))
-                     chosen-item)))))
-
-(defun smex-major-mode-commands ()
-  "Like `smex', but limited to commands that are relevant to the active major mode."
-  (interactive)
-  (let ((commands (delete-dups (append (extract-commands-from-keymap (current-local-map))
-                                       (extract-commands-from-features major-mode)))))
-    (setq commands (smex-sort-according-to-cache commands))
-    (setq commands (mapcar #'symbol-name commands))
-    (smex-read-and-run commands)))
-
-(defun smex-completing-read (choices initial-input)
-  (let ((ido-completion-map ido-completion-map)
-        (ido-setup-hook (cons 'smex-prepare-ido-bindings ido-setup-hook))
-        (ido-enable-prefix nil)
-        (ido-enable-flex-matching smex-flex-matching)
-        (ido-max-prospects 10))
-    (ido-completing-read (smex-prompt-with-prefix-arg) choices nil nil
-                         initial-input nil (car choices))))
-
-(defun smex-prompt-with-prefix-arg ()
-  (if (not current-prefix-arg)
-      smex-prompt-string
-    (concat
-     (if (eq current-prefix-arg '-)
-         "- "
-       (if (integerp current-prefix-arg)
-           (format "%d " current-prefix-arg)
-         (if (= (car current-prefix-arg) 4)
-             "C-u "
-           (format "%d " (car current-prefix-arg)))))
-     smex-prompt-string)))
-
-(defun smex-prepare-ido-bindings ()
-  (define-key ido-completion-map (kbd "C-h f") 'smex-describe-function)
-  (define-key ido-completion-map (kbd "C-h w") 'smex-where-is)
-  (define-key ido-completion-map (kbd "M-.") 'smex-find-function)
-  (define-key ido-completion-map (kbd "C-a") 'move-beginning-of-line))
-
-;;--------------------------------------------------------------------------------
-;; Cache and Maintenance
-
-(defun smex-rebuild-cache ()
-  (interactive)
-  (setq smex-cache nil)
-
-  ;; Build up list 'new-commands' and later put it at the end of 'smex-cache'.
-  ;; This speeds up sorting.
-  (let (new-commands)
-    (mapatoms (lambda (symbol)
-                (when (commandp symbol)
-                  (let ((known-command (assq symbol smex-data)))
-                    (if known-command
-                        (setq smex-cache (cons known-command smex-cache))
-                      (setq new-commands (cons (list symbol) new-commands)))))))
-    (if (eq (length smex-cache) 0)
-        (setq smex-cache new-commands)
-      (setcdr (last smex-cache) new-commands)))
-
-  (setq smex-cache (sort smex-cache 'smex-sorting-rules))
-  (smex-restore-history)
-  (setq smex-ido-cache (smex-convert-for-ido smex-cache)))
-
-(defun smex-convert-for-ido (command-items)
-  (mapcar (lambda (command-item) (symbol-name (car command-item))) command-items))
-
-(defun smex-restore-history ()
-  "Rearranges `smex-cache' according to `smex-history'"
-  (if (> (length smex-history) smex-history-length)
-      (setcdr (nthcdr (- smex-history-length 1) smex-history) nil))
-  (mapc (lambda (command)
-          (unless (eq command (caar smex-cache))
-            (let ((command-cell-position (smex-detect-position smex-cache (lambda (cell)
-                                                                (eq command (caar cell))))))
-              (if command-cell-position
-                (let ((command-cell (smex-remove-nth-cell command-cell-position smex-cache)))
-                  (setcdr command-cell smex-cache)
-                  (setq smex-cache command-cell))))))
-        (reverse smex-history)))
-
-(defun smex-sort-according-to-cache (list)
-  "Sorts a list of commands by their order in `smex-cache'"
-  (let (sorted)
-    (dolist (command-item smex-cache)
-      (let ((command (car command-item)))
-        (when (memq command list)
-          (setq sorted (cons command sorted))
-          (setq list (delq command list)))))
-    (nreverse (append list sorted))))
-
-(defun smex-update ()
-  (interactive)
-  (smex-save-history)
-  (smex-rebuild-cache))
-
-(defun smex-detect-new-commands ()
-  (let ((i 0))
-    (mapatoms (lambda (symbol) (if (commandp symbol) (setq i (1+ i)))))
-    (unless (= i smex-command-count)
-      (setq smex-command-count i))))
-
-(defun smex-auto-update (&optional idle-time)
-  "Update Smex when Emacs has been idle for IDLE-TIME."
-  (unless idle-time (setq idle-time 60))
-  (run-with-idle-timer idle-time t
-                       '(lambda () (if (smex-detect-new-commands) (smex-update)))))
-
-;;;###autoload
-(defun smex-initialize ()
-  (interactive)
-  (unless ido-mode (smex-initialize-ido))
-  (smex-load-save-file)
-  (smex-detect-new-commands)
-  (smex-rebuild-cache)
-  (add-hook 'kill-emacs-hook 'smex-save-to-file)
-  (setq smex-initialized-p t))
-
-(defun smex-initialize-ido ()
-  "Sets up a minimal Ido environment for `ido-completing-read'."
-  (ido-init-completion-maps)
-  (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup))
-
-(defun smex-load-save-file ()
-  "Loads `smex-history' and `smex-data' from `smex-save-file'"
-  (let ((save-file (expand-file-name smex-save-file)))
-    (if (file-readable-p save-file)
-        (with-temp-buffer
-          (insert-file-contents save-file)
-          (condition-case nil
-              (setq smex-history (read (current-buffer))
-                    smex-data    (read (current-buffer)))
-            (error (if (save-file-not-empty-p)
-                       (error "Invalid data in smex-save-file (%s). Can't restore history."
-                              smex-save-file)
-                     (if (not (boundp 'smex-history)) (setq smex-history))
-                     (if (not (boundp 'smex-data))    (setq smex-data))))))
-      (setq smex-history nil smex-data nil))))
-
-(defsubst save-file-not-empty-p ()
-  (string-match-p "\[^[:space:]\]" (buffer-string)))
-
-(defun smex-save-history ()
-  "Updates `smex-history'"
-  (setq smex-history nil)
-  (let ((cell smex-cache))
-    (dotimes (i smex-history-length)
-      (setq smex-history (cons (caar cell) smex-history))
-      (setq cell (cdr cell))))
-  (setq smex-history (nreverse smex-history)))
-
-(defun smex-save-to-file ()
-  (interactive)
-  (smex-save-history)
-  (with-temp-file (expand-file-name smex-save-file)
-    (ido-pp 'smex-history)
-    (ido-pp 'smex-data)))
-
-;;--------------------------------------------------------------------------------
-;; Ranking
-
-(defun smex-sorting-rules (command-item other-command-item)
-  "Returns true if COMMAND-ITEM should sort before OTHER-COMMAND-ITEM."
-  (let* ((count        (or (cdr command-item      ) 0))
-         (other-count  (or (cdr other-command-item) 0))
-         (name         (car command-item))
-         (other-name   (car other-command-item))
-         (length       (length (symbol-name name)))
-         (other-length (length (symbol-name other-name))))
-    (or (> count other-count)                         ; 1. Frequency of use
-        (and (= count other-count)
-             (or (< length other-length)              ; 2. Command length
-                 (and (= length other-length)
-                      (string< name other-name))))))) ; 3. Alphabetical order
-
-(defun smex-rank (command)
-  (let ((command-item (or (assq command smex-cache)
-                          ;; Update caches and try again if not found.
-                          (progn (smex-update)
-                                 (assq command smex-cache)))))
-    (when command-item
-      (smex-update-counter command-item)
-
-      ;; Don't touch the cache order if the chosen command
-      ;; has just been execucted previously.
-      (unless (eq command-item (car smex-cache))
-        (let (command-cell
-              (pos (smex-detect-position smex-cache (lambda (cell)
-                                                      (eq command-item (car cell))))))
-          ;; Remove the just executed command.
-          (setq command-cell (smex-remove-nth-cell pos smex-cache))
-          ;; And put it on top of the cache.
-          (setcdr command-cell smex-cache)
-          (setq smex-cache command-cell)
-
-          ;; Repeat the same for the ido cache. Should this be DRYed?
-          (setq command-cell (smex-remove-nth-cell pos smex-ido-cache))
-          (setcdr command-cell smex-ido-cache)
-          (setq smex-ido-cache command-cell)
-
-          ;; Now put the last history item back to its normal place.
-          (smex-sort-item-at smex-history-length))))))
-
-(defun smex-update-counter (command-item)
-  (let ((count (cdr command-item)))
-    (setcdr command-item
-            (if count
-                (1+ count)
-              ;; Else: Command has just been executed for the first time.
-              ;; Add it to `smex-data'.
-              (if smex-data
-                  (setcdr (last smex-data) (list command-item))
-                (setq smex-data (list command-item)))
-              1))))
-
-(defun smex-sort-item-at (n)
-  "Sorts item at position N in `smex-cache'."
-  (let* ((command-cell (nthcdr n smex-cache))
-         (command-item (car command-cell))
-         (command-count (cdr command-item)))
-    (let ((insert-at (smex-detect-position command-cell (lambda (cell)
-                       (smex-sorting-rules command-item (car cell))))))
-      ;; TODO: Should we handle the case of 'insert-at' being nil?
-      ;; This will never happen in practice.
-      (when (> insert-at 1)
-        (setq command-cell (smex-remove-nth-cell n smex-cache))
-        ;; smex-cache just got shorter by one element, so subtract '1' from insert-at.
-        (setq insert-at (+ n (- insert-at 1)))
-        (smex-insert-cell command-cell insert-at smex-cache)
-
-        ;; Repeat the same for the ido cache. DRY?
-        (setq command-cell (smex-remove-nth-cell n smex-ido-cache))
-        (smex-insert-cell command-cell insert-at smex-ido-cache)))))
-
-(defun smex-detect-position (cell function)
-  "Detects, relatively to CELL, the position of the cell
-on which FUNCTION returns true.
-Only checks cells after CELL, starting with the cell right after CELL.
-Returns nil when reaching the end of the list."
-  (let ((pos 1))
-    (catch 'break
-      (while t
-        (setq cell (cdr cell))
-        (if (not cell)
-            (throw 'break nil)
-          (if (funcall function cell) (throw 'break pos))
-          (setq pos (1+ pos)))))))
-
-(defun smex-remove-nth-cell (n list)
-  "Removes and returns the Nth cell in LIST."
-  (let* ((previous-cell (nthcdr (- n 1) list))
-         (result (cdr previous-cell)))
-    (setcdr previous-cell (cdr result))
-    result))
-
-(defun smex-insert-cell (new-cell n list)
-  "Inserts cell at position N in LIST."
-  (let* ((cell (nthcdr (- n 1) list))
-         (next-cell (cdr cell)))
-    (setcdr (setcdr cell new-cell) next-cell)))
-
-;;--------------------------------------------------------------------------------
-;; Help and Reference
-
-(defun smex-do-with-selected-item (fn)
-  (setq smex-custom-action fn)
-  (ido-exit-minibuffer))
-
-(defun smex-describe-function ()
-  (interactive)
-  (smex-do-with-selected-item (lambda (chosen)
-                           (describe-function chosen)
-                           (pop-to-buffer "*Help*"))))
-
-(defun smex-where-is ()
-  (interactive)
-  (smex-do-with-selected-item 'where-is))
-
-(defun smex-find-function ()
-  (interactive)
-  (smex-do-with-selected-item 'find-function))
-
-(defvar smex-old-message nil
-  "A temporary storage used by `smex-show-key-advice'")
-
-(defun smex-show-key-advice (command)
-  "Shows the keybinding for command, if available. Like `execute-extended-command'."
-  (let ((advice (smex-key-advice command)))
-    (when advice
-      (if (current-message)
-          (progn
-            (run-at-time 2 nil (lambda (advice)
-                                 (setq smex-old-message (current-message))
-                                 (smex-unlogged-message advice)) advice)
-
-            (run-at-time 4.5 nil (lambda (advice)
-                                 (if (equal (current-message) advice)
-                                     (smex-unlogged-message smex-old-message))) advice))
-        (smex-unlogged-message advice)))))
-
-(defun smex-key-advice (command)
-  (let ((keys (where-is-internal command)))
-    (if smex-key-advice-ignore-menu-bar
-        (setq keys (smex-filter-out-menu-bar-bindings keys)))
-    (if keys
-        (format "You can run the command `%s' with %s"
-                command
-                (mapconcat 'key-description keys ", ")))))
-
-(defsubst smex-filter-out-menu-bar-bindings (keys)
-  (delq nil (mapcar (lambda (key-vec)
-                      (unless (equal (aref key-vec 0) 'menu-bar)
-                        key-vec))
-                    keys)))
-
-(defun smex-unlogged-message (string)
-  "Bypasses logging in *Messages*"
-  (let (message-log-max)
-    (message "%s" string)))
-
-(defun extract-commands-from-keymap (map)
-  (let (commands)
-    (parse-keymap map)
-    commands))
-
-(defun parse-keymap (map)
-  (map-keymap (lambda (binding element)
-                (if (and (listp element) (eq 'keymap (car element)))
-                    (parse-keymap element)
-                          ; Strings are commands, too. Reject them.
-                  (if (and (symbolp element) (commandp element))
-                      (setq commands (cons element commands)))))
-              map))
-
-(defun extract-commands-from-features (mode)
-  (let ((library-path (symbol-file mode))
-        (mode-name (symbol-name mode))
-        commands)
-
-    (string-match "\\(.+?\\)\\(-mode\\)?$" mode-name)
-    ;; 'lisp-mode' -> 'lisp'
-    (setq mode-name (match-string 1 mode-name))
-    (if (string= mode-name "c") (setq mode-name "cc"))
-    (setq mode-name (regexp-quote mode-name))
-
-    (dolist (feature load-history)
-      (let ((feature-path (car feature)))
-        (when (and feature-path (or (equal feature-path library-path)
-                                    (string-match mode-name (file-name-nondirectory
-                                                             feature-path))))
-          (dolist (item (cdr feature))
-            (if (and (listp item) (eq 'defun (car item)))
-                (let ((function (cdr item)))
-                  (when (commandp function)
-                    (setq commands (append commands (list function))))))))))
-    commands))
-
-(defun smex-show-unbound-commands ()
-  "Shows unbound commands in a new buffer,
-sorted by frequency of use."
-  (interactive)
-  (setq smex-data (sort smex-data 'smex-sorting-rules))
-  (let ((unbound-commands (delq nil
-                                (mapcar (lambda (command-item)
-                                          (unless (where-is-internal (car command-item))
-                                            command-item))
-                                        smex-data))))
-    (view-buffer-other-window "*Smex: Unbound Commands*")
-    (setq buffer-read-only t)
-    (let ((inhibit-read-only t))
-      (erase-buffer)
-      (ido-pp 'unbound-commands))
-    (set-buffer-modified-p nil)
-    (goto-char (point-min))))
-
-(provide 'smex)
-;;; smex.el ends here

vendor/smex/smex.elc

Binary file removed.

vendor/sunrise-commander/sunrise-commander-autoloads.el

-;;; sunrise-commander-autoloads.el --- automatically extracted autoloads
-;;
-;;; Code:
-
-
-;;;### (autoloads (sr-term-cd-program sr-term-cd-newterm sr-term-cd
-;;;;;;  sr-term sunrise-cd sr-dired sunrise sr-virtual-mode sr-mode)
-;;;;;;  "sunrise-commander" "sunrise-commander.el" (20617 51588))
-;;; Generated autoloads from sunrise-commander.el
-
-(autoload 'sr-mode "sunrise-commander" "\
-Two-pane file manager for Emacs based on Dired and inspired by MC.
-The following keybindings are available:
-
-        /, j .......... go to directory
-        p, n .......... move cursor up/down
-        M-p, M-n ...... move cursor up/down in passive pane
-        ^, J .......... go to parent directory
-        M-^, M-J ...... go to parent directory in passive pane
-        Tab ........... switch to other pane
-        C-Tab.......... switch to viewer window
-        C-c Tab ....... switch to viewer window (console compatible)
-        RET, f ........ visit selected file/directory
-        M-RET, M-f .... visit selected file/directory in passive pane
-        C-c RET ....... visit selected in passive pane (console compatible)
-        b ............. visit selected file/directory in default browser
-        F ............. visit all marked files, each in its own window
-        C-u F ......... visit all marked files in the background
-        o,v ........... quick visit selected file (scroll with C-M-v, C-M-S-v)
-        C-u o, C-u v .. kill quick-visited buffer (restores normal scrolling)
-        X ............. execute selected file
-        C-u X.......... execute selected file with arguments
-
-        + ............. create new directory
-        M-+ ........... create new empty file(s)
-        C ............. copy marked (or current) files and directories
-        R ............. rename marked (or current) files and directories
-        D ............. delete marked (or current) files and directories
-        S ............. soft-link selected file/directory to passive pane
-        Y ............. do relative soft-link of selected file in passive pane
-        H ............. hard-link selected file to passive pane
-        K ............. clone selected files and directories into passive pane
-        M-C ........... copy (using traditional dired-do-copy)
-        M-R ........... rename (using traditional dired-do-rename)
-        M-D ........... delete (using traditional dired-do-delete)
-        M-S............ soft-link (using traditional dired-do-symlink)
-        M-Y............ do relative soft-link (traditional dired-do-relsymlink)
-        M-H............ hard-link selected file/directory (dired-do-hardlink)
-        A ............. search marked files for regular expression
-        Q ............. perform query-replace-regexp on marked files
-        C-c s ......... start a \"sticky\" interactive search in the current pane
-
-        M-a ........... move to beginning of current directory
-        M-e ........... move to end of current directory
-        M-y ........... go to previous directory in history
-        M-u ........... go to next directory in history
-        C-M-y ......... go to previous directory in history on passive pane
-        C-M-u ......... go to next directory in history on passive pane
-
-        g, C-c C-c .... refresh pane
-        s ............. sort entries (by name, number, size, time or extension)
-        r ............. reverse the order of entries in the active pane (sticky)
-        C-o ........... show/hide hidden files (requires dired-omit-mode)
-        C-Backspace ... hide/show file attributes in pane
-        C-c Backspace . hide/show file attributes in pane (console compatible)
-        y ............. show file type / size of selected files and directories.
-        M-l ........... truncate/continue long lines in pane
-        C-c v ......... put current panel in VIRTUAL mode
-        C-c C-v ....... create new pure VIRTUAL buffer
-        C-c C-w ....... browse directory tree using w3m
-
-        M-t ........... transpose panes
-        M-o ........... synchronize panes
-        C-c C-s ....... change panes layout (vertical/horizontal/top-only)
-        [ ............. enlarges the right pane by 5 columns
-        ] ............. enlarges the left pane by 5 columns
-        } ............. enlarges the panes vertically by 1 row
-        C-} ........... enlarges the panes vertically as much as it can
-        C-c } ......... enlarges the panes vertically as much as it can
-        { ............. shrinks the panes vertically by 1 row
-        C-{ ........... shrinks the panes vertically as much as it can
-        C-c { ......... shrinks the panes vertically as much as it can
-        \\ ............. restores the size of all windows back to «normal»
-        C-c C-z ....... enable/disable synchronized navigation
-
-        C-= ........... smart compare files (ediff)
-        C-c = ......... smart compare files (console compatible)
-        = ............. fast smart compare files (plain diff)
-        C-M-= ......... compare panes
-        C-x = ......... compare panes (console compatible)
-
-        C-c C-f ....... execute Find-dired in Sunrise VIRTUAL mode
-        C-c C-n ....... execute find-Name-dired in Sunrise VIRTUAL mode
-        C-c C-g ....... execute find-Grep-dired in Sunrise VIRTUAL mode
-        C-u C-c C-g ... execute find-Grep-dired with additional grep options
-        C-c C-l ....... execute Locate in Sunrise VIRTUAL mode
-        C-c C-r ....... browse list of Recently visited files (requires recentf)
-        C-c C-c ....... [after find, locate or recent] dismiss virtual buffer
-        C-c / ......... narrow the contents of current pane using fuzzy matching
-        C-c b ......... partial Branch view of selected items in current pane
-        C-c p ......... Prune paths matching regular expression from current pane
-        ; ............. follow file (go to same directory as selected file)
-        M-; ........... follow file in passive pane
-        C-M-o ......... follow a projection of current directory in passive pane
-
-        C-> ........... save named checkpoint (a.k.a. \"bookmark panes\")
-        C-c > ......... save named checkpoint (console compatible)
-        C-.    ........ restore named checkpoint
-        C-c .  ........ restore named checkpoint
-
-        C-x C-q ....... put pane in Editable Dired mode (commit with C-c C-c)
-        @! ............ fast backup files (not dirs!), each to [filename].bak
-
-        C-c t ......... open new terminal or switch to already open one
-        C-c T ......... open terminal AND/OR change directory to current
-        C-c C-t ....... open always a new terminal in current directory
-        C-c M-t ....... open a new terminal using an alternative shell program
-        q, C-x k ...... quit Sunrise Commander, restore previous window setup
-        M-q ........... quit Sunrise Commander, don't restore previous windows
-
-Additionally, the following traditional commander-style keybindings are provided
-\(these may be disabled by customizing the `sr-use-commander-keys' option):
-
-        F2 ............ go to directory
-        F3 ............ quick visit selected file
-        F4 ............ visit selected file
-        F5 ............ copy marked (or current) files and directories
-        F6 ............ rename marked (or current) files and directories
-        F7 ............ create new directory
-        F8 ............ delete marked (or current) files and directories
-        F10 ........... quit Sunrise Commander
-        C-F3 .......... sort contents of current pane by name
-        C-F4 .......... sort contents of current pane by extension
-        C-F5 .......... sort contents of current pane by time
-        C-F6 .......... sort contents of current pane by size
-        C-F7 .......... sort contents of current pane numerically
-        S-F7 .......... soft-link selected file/directory to passive pane
-        Insert ........ mark file
-        C-PgUp ........ go to parent directory
-
-Any other dired keybinding (not overridden by any of the above) can be used in
-Sunrise, like G for changing group, M for changing mode and so on.
-
-Some more bindings are available in terminals opened using any of the Sunrise
-functions (i.e. one of: C-c t, C-c T, C-c C-t, C-c M-t):
-
-        C-c Tab ....... switch focus to the active pane
-        C-c t ......... cycle through all currently open terminals
-        C-c T ......... cd to the directory in the active pane
-        C-c C-t ....... open new terminal, cd to directory in the active pane
-        C-c ; ......... follow the current directory in the active pane
-        C-c { ......... shrink the panes vertically as much as possible
-        C-c } ......... enlarge the panes vertically as much as possible
-        C-c \\ ......... restore the size of all windows back to «normal»
-        C-c C-j ....... put terminal in line mode
-        C-c C-k ....... put terminal back in char mode
-
-The following bindings are available only in line mode (eshell is considered to
-be *always* in line mode):
-
-        M-<up>, M-P ... move cursor up in the active pane
-        M-<down>, M-N . move cursor down in the active pane
-        M-Return ...... visit selected file/directory in the active pane
-        M-J ........... go to parent directory in the active pane
-        M-G ........... refresh active pane
-        M-Tab ......... switch to passive pane (without leaving the terminal)
-        M-M ........... mark selected file/directory in the active pane
-        M-Backspace ... unmark previous file/directory in the active pane
-        M-U ........... remove all marks from the active pane
-        C-Tab ......... switch focus to the active pane
-
-In a terminal in line mode the following substitutions are also performed
-automatically:
-
-       %f - expands to the currently selected file in the left pane
-       %F - expands to the currently selected file in the right pane
-       %m - expands to the list of paths of all marked files in the left pane
-       %M - expands to the list of paths of all marked files in the right pane
-       %n - expands to the list of names of all marked files in the left pane
-       %N - expands to the list of names of all marked files in the right pane
-       %d - expands to the current directory in the left pane
-       %D - expands to the current directory in the right pane
-       %a - expands to the list of paths of all marked files in the active pane
-       %A - expands to the current directory in the active pane
-       %p - expands to the list of paths of all marked files in the passive pane
-       %P - expands to the current directory in the passive pane
-       %% - inserts a single % sign.
-
-\(fn)" t nil)
-
-(autoload 'sr-virtual-mode "sunrise-commander" "\
-Sunrise Commander Virtual Mode. Useful for reusing find and locate results.
-
-\(fn)" t nil)
-
-(autoload 'sunrise "sunrise-commander" "\
-Toggle the Sunrise Commander file manager.
-If LEFT-DIRECTORY is given, the left window will display that
-directory (same for RIGHT-DIRECTORY). Specifying nil for any of
-these values uses the default, ie. $HOME.
-
-\(fn &optional LEFT-DIRECTORY RIGHT-DIRECTORY FILENAME)" t nil)
-
-(autoload 'sr-dired "sunrise-commander" "\
-Visit the given target (file or directory) in `sr-mode'.
-
-\(fn &optional TARGET SWITCHES)" t nil)
-
-(autoload 'sunrise-cd "sunrise-commander" "\
-Toggle the Sunrise Commander FM keeping the current file in focus.
-If Sunrise is off, enable it and focus the file displayed in the current buffer.
-If Sunrise is on, disable it and switch to the buffer currently displayed in the
-viewer window.
-
-\(fn)" t nil)
- (autoload 'sr-checkpoint-handler "sunrise-commander" "" t)
-
-(autoload 'sr-term "sunrise-commander" "\
-Run terminal in a new buffer or switch to an existing one.
-If the optional argument CD is non-nil, directory is changed to
-the current one in the active pane. A non-nil NEWTERM argument
-forces the creation of a new terminal. If PROGRAM is provided
-and exists in `exec-path', then it will be used instead of the
-default `sr-terminal-program'.
-
-\(fn &optional CD NEWTERM PROGRAM)" t nil)
-
-(autoload 'sr-term-cd "sunrise-commander" "\
-Run terminal in a new buffer or switch to an existing one.
-cd's to the current directory of the active pane.
-
-\(fn)" t nil)
-
-(autoload 'sr-term-cd-newterm "sunrise-commander" "\
-Open a NEW terminal (don't switch to an existing one).
-cd's to the current directory of the active pane.
-
-\(fn)" t nil)
-
-(autoload 'sr-term-cd-program "sunrise-commander" "\
-Open a NEW terminal using PROGRAM as the shell.
-
-\(fn &optional PROGRAM)" t nil)
-
-;;;***
-
-;;;### (autoloads nil "sunrise-x-buttons" "sunrise-x-buttons.el"
-;;;;;;  (20617 51588))
-;;; Generated autoloads from sunrise-x-buttons.el
- (eval-after-load 'sunrise-commander '(sr-extend-with 'sunrise-x-buttons))
-
-;;;***
-
-;;;### (autoloads nil "sunrise-x-loop" "sunrise-x-loop.el" (20617
-;;;;;;  51588))
-;;; Generated autoloads from sunrise-x-loop.el
- (eval-after-load 'sunrise-commander '(sr-extend-with 'sunrise-x-loop))
-
-;;;***
-
-;;;### (autoloads nil "sunrise-x-mirror" "sunrise-x-mirror.el" (20617
-;;;;;;  51588))
-;;; Generated autoloads from sunrise-x-mirror.el
- (eval-after-load 'sunrise-commander '(sr-extend-with 'sunrise-x-mirror))
-
-;;;***
-
-;;;### (autoloads nil "sunrise-x-modeline" "sunrise-x-modeline.el"
-;;;;;;  (20617 51588))
-;;; Generated autoloads from sunrise-x-modeline.el
- (eval-after-load 'sunrise-commander '(sr-extend-with 'sunrise-x-modeline))
-
-;;;***
-
-;;;### (autoloads nil "sunrise-x-popviewer" "sunrise-x-popviewer.el"
-;;;;;;  (20617 51588))
-;;; Generated autoloads from sunrise-x-popviewer.el
- (eval-after-load 'sunrise-commander '(sr-extend-with 'sunrise-x-popviewer))
-
-;;;***
-
-;;;### (autoloads nil "sunrise-x-tabs" "sunrise-x-tabs.el" (20617
-;;;;;;  51588))
-;;; Generated autoloads from sunrise-x-tabs.el
- (eval-after-load 'sunrise-commander '(sr-extend-with 'sunrise-x-tabs))
-
-;;;***
-
-;;;### (autoloads (sr-tree-mode) "sunrise-x-tree" "sunrise-x-tree.el"
-;;;;;;  (20617 51588))
-;;; Generated autoloads from sunrise-x-tree.el
-
-(autoload 'sr-tree-mode "sunrise-x-tree" "\
-Tree view for the Sunrise Commander file manager.
-
-\(fn)" t nil)
- (eval-after-load 'sunrise-commander '(sr-extend-with 'sunrise-x-tree))
-
-;;;***
-
-;;;### (autoloads nil "sunrise-x-w32-addons" "sunrise-x-w32-addons.el"
-;;;;;;  (20617 51588))
-;;; Generated autoloads from sunrise-x-w32-addons.el
- (eval-after-load 'sunrise-commander '(sr-extend-with 'sunrise-x-w32-addons))
-
-;;;***
-
-;;;### (autoloads nil nil ("sunrise-commander-pkg.el" "sunrise-x-checkpoints.el"
-;;;;;;  "sunrise-x-old-checkpoints.el") (20617 51588 673000))
-
-;;;***
-
-(provide 'sunrise-commander-autoloads)
-;; Local Variables:
-;; version-control: never
-;; no-byte-compile: t
-;; no-update-autoloads: t
-;; coding: utf-8
-;; End:
-;;; sunrise-commander-autoloads.el ends here

vendor/sunrise-commander/sunrise-commander-pkg.el

-(define-package "sunrise-commander" "20121020.1201" "two-pane file manager for Emacs based on Dired and inspired by MC [source: github]" 'nil)
-

vendor/sunrise-commander/sunrise-commander.el

-;;; sunrise-commander.el --- two-pane file manager for Emacs based on Dired and inspired by MC  -*- lexical-binding: t -*-
-
-;; Copyright (C) 2007-2012 José Alfredo Romero Latouche.
-
-;; Author: José Alfredo Romero L. <escherdragon@gmail.com>
-;;	Štěpán Němec <stepnem@gmail.com>
-;; Maintainer: José Alfredo Romero L. <escherdragon@gmail.com>
-;; Created: 24 Sep 2007
-;; Version: 6
-;; RCS Version: $Rev: 439 $
-;; Keywords: files, dired, midnight commander, norton, orthodox
-;; URL: http://www.emacswiki.org/emacs/sunrise-commander.el
-;; Compatibility: GNU Emacs 22+
-
-;; This file is not part of GNU Emacs.
-
-;; This program is free software: you can redistribute it and/or modify it under
-;; the terms of the GNU General Public License as published by the Free Software
-;; Foundation, either version 3 of the License, or (at your option) any later
-;; version.
-;;
-;; This program is distributed in the hope that it will be useful, but WITHOUT
-;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more de-
-;; tails.
-
-;; You should have received a copy of the GNU General Public License along with
-;; this program. If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; The Sunrise Commmander is an double-pane file manager for Emacs. It's built
-;; atop of Dired and takes advantage of all its power, but also provides many
-;; handy features of its own:
-
-;; * Sunrise is implemented as a derived major mode confined inside the pane
-;; buffers, so its buffers and Dired ones can live together without easymenu or
-;; viper to avoid key binding collisions.
-
-;; * It automatically closes unused buffers and tries to never keep open more
-;; than the one or two used to display the panes, though this behavior may be
-;; disabled if desired.
-
-;; * Each pane has its own history stack: press M-y / M-u for moving backwards /
-;; forwards in the history of directories.
-
-;; * Press M-t to swap (transpose) the panes.
-
-;; * Press C-= for "smart" file comparison using `ediff'. It compares together
-;; the first two files marked on each pane or, if no files have been marked, it
-;; assumes that the second pane contains a file with the same name as the
-;; selected one and tries to compare these two. You can also mark whole lists of
-;; files to be compared and then just press C-= for comparing the next pair.
-
-;; * Press = for fast "smart" file comparison -- like above, but using regular
-;; diff.
-
-;; * Press C-M-= for directory comparison (by date / size / contents of files).
-
-;; * Press C-c C-s to change the layout of the panes (horizontal/vertical/top)
-
-;; * Press C-c / to interactively refine the contents of the current pane using
-;; fuzzy (a.k.a. flex) matching, then:
-;;    - press Delete or Backspace to revert the buffer to its previous state
-;;    - press Return, C-n or C-p to exit and accept the current narrowed state
-;;    - press Esc or C-g to abort the operation and revert the buffer
-;;    - use ! to prefix characters that should NOT appear after a given position
-;; Once narrowed and accepted, you can restore the original contents of the pane
-;; by pressing g (revert-buffer).
-
-;; * Sticky search: press C-c s to launch an interactive search that will remain
-;; active from directory to directory, until you hit a regular file or press C-g
-
-;; * Press C-x C-q to put the current pane in Editable Dired mode (allows to
-;; edit the pane as if it were a regular file -- press C-c C-c to commit your
-;; changes to the filesystem, or C-c C-k to abort).
-
-;; * Press y to recursively calculate the total size (in bytes) of all files and
-;; directories currently selected/marked in the active pane.
-
-;; * Sunrise VIRTUAL mode integrates dired-virtual mode to Sunrise, allowing to
-;; capture find and locate results in regular files and to use them later as if
-;; they were directories with all Dired and Sunrise operations at your
-;; fingertips.
-;; The results of the following operations are displayed in VIRTUAL mode:
-;;    - find-name-dired (press C-c C-n),
-;;    - find-grep-dired (press C-c C-g),
-;;    - find-dired      (press C-c C-f),
-;;    - locate          (press C-c C-l),
-;;    - list all recently visited files (press C-c C-r -- requires recentf),
-;;    - list all directories in active pane's history ring (press C-c C-d).
-
-;; * Supports AVFS (http://avf.sourceforge.net/) for transparent navigation
-;; inside compressed archives (*.zip, *.tgz, *.tar.bz2, *.deb, etc. etc.)
-;; You need to have AVFS with coda or fuse installed and running on your system
-;; for this to work, though.
-
-;; * Opening terminals directly from Sunrise:
-;;    - Press C-c C-t to inconditionally open a new terminal into the currently
-;;      selected directory in the active pane.
-;;    - Use C-c t to switch to the last opened terminal, or (when already inside
-;;      a terminal) to cycle through all open terminals.
-;;    - Press C-c T to switch to the last opened terminal and change directory
-;;      to the one in the current directory.
-;;    - Press C-c M-t to be prompted for a program name, and then open a new
-;;      terminal using that program into the currently selected directory
-;;      (eshell is a valid value; if no program can be found with the given name
-;;      then the value of `sr-terminal-program' is used instead).
-
-;; * Terminal integration and Command line expansion: integrates tightly with
-;; `eshell' and `term-mode' to allow interaction between terminal emulators in
-;; line mode (C-c C-j) and the panes: the most important navigation commands
-;; (up, down, mark, unmark, go to parent dir) can be executed on the active pane
-;; directly from the terminal by pressing the usual keys with Meta: <M-up>,
-;; <M-down>, etc. Additionally, the following substitutions are automagically
-;; performed in `eshell' and `term-line-mode':
-;;     %f - expands to the currently selected file in the left pane
-;;     %F - expands to the currently selected file in the right pane
-;;     %m - expands to the list of paths of all marked files in the left pane
-;;     %M - expands to the list of paths of all marked files in the right pane
-;;     %n - expands to the list of names of all marked files in the left pane
-;;     %N - expands to the list of names of all marked files in the right pane
-;;     %d - expands to the current directory in the left pane
-;;     %D - expands to the current directory in the right pane
-;;     %a - expands to the list of paths of all marked files in the active pane
-;;     %A - expands to the current directory in the active pane
-;;     %p - expands to the list of paths of all marked files in the passive pane
-;;     %P - expands to the current directory in the passive pane
-
-;; * Cloning of complete directory trees: press K to clone the selected files
-;; and directories into the passive pane. Cloning is a more general operation
-;; than copying, in which all directories are recursively created with the same
-;; names and structures at the destination, while what happens to the files
-;; within them depends on the option you choose:
-;;    - "(D)irectories only" ignores all files, copies only directories,
-;;    - "(C)opies" performs a regular recursive copy of all files and dirs,
-;;    - "(H)ardlinks" makes every new file a (hard) link to the original one
-;;    - "(S)ymlinks" creates absolute symbolic links for all files in the tree,
-;;    - "(R)elative symlinks” creates relative symbolic links.
-
-;; * Passive navigation: the usual navigation keys (n, p, Return, U, ;) combined
-;; with Meta allow to move across the passive pane without actually having to
-;; switch to it.
-
-;; * Synchronized navigation: press C-c C-z to enable / disable synchronized
-;; navigation. In this mode, the passive navigation keys (M-n, M-p, M-Return,
-;; etc.) operate on both panes simultaneously. I've found this quite useful for
-;; comparing hierarchically small to medium-sized directory trees (for large to
-;; very large directory trees one needs something on the lines of diff -r
-;; though).
-
-;; * And much more -- press ? while in Sunrise mode for basic help, or h for a
-;; complete list of all keybindings available (use C-e and C-y to scroll).
-
-;; There is no help window like in MC, but if you really miss it, just get and
-;; install the sunrise-x-buttons extension.
-
-;; A lot of this code was once adapted from Kevin's mc.el, but it has evolved
-;; considerably since then. Another part (the code for file copying and
-;; renaming) derives originally from the Dired extensions written by Kurt
-;; Nørmark for LAML (http://www.cs.aau.dk/~normark/scheme/distribution/laml/).
-
-;; It was written on GNU Emacs 24 on Linux and tested on GNU Emacs 22, 23 and 24
-;; for Linux and on EmacsW32 (version 23) for Windows. I have also received
-;; feedback from users reporting it works OK on the Mac. It does not work either
-;; on GNU Emacs 21 or XEmacs -- please drop me a line if you would like to help
-;; porting it. All contributions and/or bug reports will be very welcome.
-
-;; For more details on the file manager, several available extensions and many
-;; cool tips & tricks visit http://www.emacswiki.org/emacs/Sunrise_Commander
-
-;;; Installation and Usage:
-
-;; 1) Put this file somewhere in your Emacs `load-path'.
-
-;; 2) Add a (require 'sunrise-commander) to your .emacs file.
-
-;; 3) Choose some unused extension for files to be opened in Sunrise VIRTUAL
-;; mode and add it to `auto-mode-alist', e.g. if you want to name your virtual
-;; directories like *.svrm just add to your .emacs file a line like the
-;; following:
-;;
-;;     (add-to-list 'auto-mode-alist '("\\.srvm\\'" . sr-virtual-mode))
-
-;; 4) Evaluate the new lines, or reload your .emacs file, or restart Emacs.
-
-;; 5) Type M-x sunrise to invoke the Sunrise Commander (or much better: bind the
-;; function to your favorite key combination). The command `sunrise-cd' invokes
-;; Sunrise and automatically selects the current file wherever it is in the
-;; filesystem. Type h at any moment for information on available key bindings.
-
-;; 6) Type M-x customize-group <RET> sunrise <RET> to customize options, fonts
-;; and colors (activate AVFS support here, too).
-
-;; 7) Enjoy :)
-
-;;; Code:
-
-(require 'advice)
-(require 'desktop)
-(require 'dired)
-(require 'dired-aux)
-(require 'dired-x)
-(require 'enriched)
-(require 'esh-mode)
-(require 'find-dired)
-(require 'font-lock)
-(require 'hl-line)
-(require 'sort)
-(require 'term)
-(eval-when-compile (require 'cl)
-                   (require 'recentf)
-                   (require 'tramp))
-
-(eval-and-compile
-  (unless (fboundp 'cl-labels)
-    (defalias 'cl-labels 'labels)))
-
-(defgroup sunrise nil
-  "The Sunrise Commander File Manager."
-  :group 'files)
-
-(defcustom sr-show-file-attributes t
-  "Whether to initially display file attributes in Sunrise panes.
-You can always toggle file attributes display pressing
-\\<sr-mode-map>\\[sr-toggle-attributes]."
-  :group 'sunrise
-  :type 'boolean)
-
-(defcustom sr-autoload-extensions t
-  "Whether to load extensions immediately after their declaration, or when the
-SC core is loaded (e.g. when using autoload cookies)."
-  :group 'sunrise
-  :type 'boolean)
-
-(defcustom sr-show-hidden-files nil
-  "Whether to initially display hidden files in Sunrise panes.
-You can always toggle hidden files display pressing
-\\<sr-mode-map>\\[dired-omit-mode].
-You can also customize what files are considered hidden by setting
-`dired-omit-files' and `dired-omit-extensions' in your .emacs file."
-  :group 'sunrise
-  :type 'boolean)
-
-(defcustom sr-terminal-kill-buffer-on-exit t
-  "Whether to kill terminal buffers after their shell process ends."
-  :group 'sunrise
-  :type 'boolean)
-
-(defcustom sr-terminal-program "eshell"
-  "The program to use for terminal emulation.
-If this value is set to \"eshell\", the Emacs shell (`eshell')
-will be used."
-  :group 'sunrise
-  :type 'string)
-
-(defcustom sr-listing-switches "-al"
-  "Listing switches passed to `ls' when building Sunrise buffers.
-\(Cf. `dired-listing-switches'.)
-  Most portable value: -al
-  Recommended value on GNU systems: \
---time-style=locale --group-directories-first -alDhgG"
-  :group 'sunrise
-  :type 'string)
-
-(defcustom sr-virtual-listing-switches "-ald"
-  "Listing switches for building buffers in `sr-virtual-mode'.
-Should not contain the -D option. See also `sr-listing-switches'."
-  :group 'sunrise
-  :type 'string)
-
-(defcustom sr-avfs-root nil
-  "Root of the AVFS virtual filesystem used for navigating compressed archives.
-Setting this value activates AVFS support."
-  :group 'sunrise
-  :type '(choice
-          (const :tag "AVFS support disabled" nil)
-          (directory :tag "AVFS root directory")))
-
-(defcustom sr-avfs-handlers-alist '(("\\.[jwesh]ar$" . "#uzip/")
-                                    ("\\.wsar$"      . "#uzip/")
-                                    ("\\.xpi$"       . "#uzip/")
-                                    ("\\.apk$"       . "#uzip/")
-                                    ("\\.iso$"       . "#iso9660/")
-                                    ("\\.patch$"     . "#/")
-                                    ("\\.txz$"       . "#/")
-                                    ("."             . "#/"))
-  "List of AVFS handlers to manage specific file extensions."
-  :group 'sunrise
-  :type 'alist)
-
-(defcustom sr-md5-shell-command "md5sum %f | cut -d' ' -f1 2>/dev/null"
-  "Shell command to use for calculating MD5 sums for files.
-Used when comparing directories using the ``(c)ontents'' option.
-Use %f as a placeholder for the name of the file."
-  :group 'sunrise
-  :type 'string)
-
-(defcustom sr-window-split-style 'horizontal
-  "The current window split configuration.
-May be `horizontal', `vertical' or `top'."
-  :group 'sunrise
-  :type '(choice
-          (const horizontal)
-          (const vertical)
-          (const top)))
-
-(defcustom sr-windows-locked t
-  "When non-nil, vertical size of the panes will remain constant."
-  :group 'sunrise
-  :type 'boolean)
-
-(defcustom sr-windows-default-ratio 66
-  "Percentage of the total height of the frame to use by default for the Sunrise
-Commander panes."
-  :group 'sunrise
-  :type 'integer
-  :set (defun sr-set-windows-default-ratio (symbol value)
-         "Setter function for the `sr-windows-default-ratio' custom option."
-         (if (and (integerp value) (>= value 0) (<= value 100))
-             (set-default symbol value)
-           (error "Invalid value: %s" value))))
-
-(defcustom sr-history-length 20
-  "Number of entries to keep in each pane's history rings."
-  :group 'sunrise
-  :type 'integer)
-
-(defcustom sr-kill-unused-buffers t
-  "Whether buffers should be killed automatically by Sunrise when not displayed
-in any of the panes."
-  :group 'sunrise
-  :type 'boolean)
-
-(defcustom sr-confirm-kill-viewer t
-  "Whether to ask for confirmation before killing a buffer opened in quick-view
-mode."
-  :group 'sunrise
-  :type 'boolean)
-
-(defcustom sr-attributes-display-mask nil
-  "Contols hiding/transforming columns with `sr-toggle-attributes'.
-If set, its value must be a list of symbols, one for each
-attributes column. If the symbol is nil, then the corresponding
-column will be hidden, and if it's not nil then the column will
-be left untouched. The symbol may also be the name of a function
-that takes one string argument and evaluates to a different
-string -- in this case this function will be used to transform
-the contents of the corresponding column and its result will be
-displayed instead."
-  :group 'sunrise
-  :type '(repeat symbol))
-
-(defcustom sr-fast-backup-extension ".bak"
-  "Determines the extension to append to the names of new files
-created with the `sr-fast-backup-files' function (@!). This can
-be either a simple string or an s-expression to be evaluated at
-run-time."
-  :group 'sunrise
-  :type '(choice
-          (string :tag "Literal text")
-          (sexp :tag "Symbolic expression")))
-
-(defcustom sr-traditional-other-window nil
-  "Sunrise modifies the behavior of the `other-window' command,
-so that focus is always given to the currently selected pane when
-switching from external windows. If you'd prefer the original
-Emacs behavior instead, then set this flag to t."
-  :group 'sunrise
-  :type 'boolean)
-
-(defcustom sr-fuzzy-negation-character ?!
-  "Character to use for negating patterns when fuzzy-narrowing a pane."
-  :group 'sunrise
-  :type '(choice
-          (const :tag "Fuzzy matching negation disabled" nil)
-          (character :tag "Fuzzy matching negation character" ?!)))
-
-(defcustom sr-init-hook nil
-  "List of functions to be called before the Sunrise panes are displayed."
-  :group 'sunrise
-  :type 'hook
-  :options '(auto-insert))
-
-(defcustom sr-start-hook nil
-  "List of functions to be called after the Sunrise panes are displayed."
-  :group 'sunrise
-  :type 'hook
-  :options '(auto-insert))
-
-(defcustom sr-refresh-hook nil
-  "List of functions to be called every time a pane is refreshed."
-  :group 'sunrise
-  :type 'hook
-  :options '(auto-insert))
-
-(defcustom sr-quit-hook nil
-  "List of functions to be called after the Sunrise panes are hidden."
-  :group 'sunrise
-  :type 'hook
-  :options '(auto-insert))
-
-(defvar sr-restore-buffer nil
-  "Buffer to restore when Sunrise quits.")
-
-(defvar sr-prior-window-configuration nil
-  "Window configuration before Sunrise was started.")
-
-(defvar sr-running nil
-  "True when Sunrise commander mode is running.")
-
-(defvar sr-synchronized nil
-  "True when synchronized navigation is on")
-
-(defvar sr-current-window-overlay nil
-  "Holds the current overlay which marks the current Dired buffer.")
-
-(defvar sr-clex-hotchar-overlay nil
-  "Overlay used to highlight the hot character (%) during CLEX operations.")
-
-(defvar sr-left-directory "~/"
-  "Dired directory for the left window. See variable `dired-directory'.")
-
-(defvar sr-left-buffer nil
-  "Dired buffer for the left window.")
-
-(defvar sr-left-window nil
-  "The left window of Dired.")
-
-(defvar sr-right-directory "~/"
-  "Dired directory for the right window. See variable `dired-directory'.")
-
-(defvar sr-right-buffer nil
-  "Dired buffer for the right window.")
-
-(defvar sr-right-window nil
-  "The right window of Dired.")
-
-(defvar sr-current-frame nil
-  "The frame Sunrise is active on (if any).")
-
-(defvar sr-this-directory "~/"
-  "Dired directory in the active pane.
-This isn't necessarily the same as `dired-directory'.")
-
-(defvar sr-other-directory "~/"
-  "Dired directory in the passive pane.")
-
-(defvar sr-selected-window 'left
-  "The window to select when Sunrise starts up.")
-
-(defvar sr-selected-window-width nil
-  "The width the selected window should have on startup.")
-
-(defvar sr-history-registry '((left) (right))
-  "Registry of visited directories for both panes.")
-
-(defvar sr-history-stack '((left 0 . 0) (right 0 . 0))
-  "History stack counters.
-The first counter on each side tracks (by value) the absolute
-depth of the stack and (by sign) the direction it is currently
-being traversed. The second counter points at the position of the
-element that is immediately beneath the top of the stack.")
-
-(defvar sr-ti-openterms nil
-  "Stack of currently open terminal buffers.")
-
-(defvar sr-ediff-on nil
-  "Flag that indicates whether an `ediff' is being currently done.")
-
-(defvar sr-clex-on nil
-  "Flag that indicates that a CLEX operation is taking place.")
-
-(defvar sr-virtual-buffer nil
-  "Local flag that indicates the current buffer was originally in
-  VIRTUAL mode.")
-
-(defvar sr-dired-directory ""
-  "Directory inside which `sr-mode' is currently active.")
-
-(defvar sr-start-message
-  "Been coding all night? Enjoy the Sunrise! (or press q to quit)"
-  "Message to display when Sunrise is started.")
-
-(defvar sr-panes-height nil
-  "Current height of the pane windows.
-Initial value is 2/3 the viewport height.")
-
-(defvar sr-current-path-faces nil
-  "List of faces to display the path in the current pane (first wins)")
-(make-variable-buffer-local 'sr-current-path-faces)
-
-(defvar sr-inhibit-highlight nil
-  "Special variable used to temporarily inhibit highlighting in panes.")
-
-(defvar sr-find-items nil
-  "Special variable used by `sr-find' to control the scope of find operations.")
-
-(defvar sr-desktop-save-handlers nil
-  "List of extension-defined handlers to save Sunrise buffers with desktop.")
-
-(defvar sr-desktop-restore-handlers nil
-  "List of extension-defined handlers to restore Sunrise buffers from desktop.")
-
-(defvar sr-backup-buffer nil
-  "Variable holding a buffer-local value of the backup buffer.")
-(make-variable-buffer-local 'sr-backup-buffer)
-
-(defvar sr-goto-dir-function nil
-  "Function to use to navigate to a given directory, or nil to do
-the default.  The function receives one argument DIR, which is
-the directory to go to.")
-
-(defconst sr-side-lookup (list '(left . right) '(right . left))
-  "Trivial alist used by the Sunrise Commander to lookup its own passive side.")
-
-(defface sr-active-path-face
-  '((((type tty) (class color) (min-colors 8))
-     :background "green" :foreground "yellow" :bold t)
-    (((type tty) (class mono)) :inverse-video t)
-    (t :background "#ace6ac" :foreground "yellow" :bold t :height 120))
-  "Face of the directory path in the active pane."
-  :group 'sunrise)
-
-(defface sr-passive-path-face
-  '((((type tty) (class color) (min-colors 8) (background dark))
-     :background "black" :foreground "cyan")
-    (((type tty) (class color) (min-colors 8) (background light))
-     :background "white" :foreground "cyan")
-    (t :background "white" :foreground "lightgray" :bold t :height 120))
-  "Face of the directory path in the passive pane."
-  :group 'sunrise)
-
-(defface sr-editing-path-face
-  '((t :background "red" :foreground "yellow" :bold t :height 120))
-  "Face of the directory path in the active pane while in editable pane mode."
-  :group 'sunrise)
-
-(defface sr-highlight-path-face
-  '((t :background "yellow" :foreground "#ace6ac" :bold t :height 120))
-  "Face of the directory path on mouse hover."
-  :group 'sunrise)
-
-(defface sr-clex-hotchar-face
-  '((t :foreground "red" :bold t))
-  "Face of the hot character (%) in CLEX mode.
-Indicates that a CLEX substitution may be about to happen."
-  :group 'sunrise)
-
-;;; ============================================================================
-;;; This is the core of Sunrise: the main idea is to apply `sr-mode' only inside
-;;; Sunrise buffers while keeping all of `dired-mode' untouched.
-
-;;; preserve this variable when switching from `dired-mode' to another mode
-(put 'dired-subdir-alist 'permanent-local t)
-
-;;;###autoload
-(define-derived-mode sr-mode dired-mode "Sunrise Commander"
-  "Two-pane file manager for Emacs based on Dired and inspired by MC.
-The following keybindings are available:
-
-        /, j .......... go to directory
-        p, n .......... move cursor up/down
-        M-p, M-n ...... move cursor up/down in passive pane
-        ^, J .......... go to parent directory
-        M-^, M-J ...... go to parent directory in passive pane
-        Tab ........... switch to other pane
-        C-Tab.......... switch to viewer window
-        C-c Tab ....... switch to viewer window (console compatible)
-        RET, f ........ visit selected file/directory
-        M-RET, M-f .... visit selected file/directory in passive pane
-        C-c RET ....... visit selected in passive pane (console compatible)
-        b ............. visit selected file/directory in default browser
-        F ............. visit all marked files, each in its own window
-        C-u F ......... visit all marked files in the background
-        o,v ........... quick visit selected file (scroll with C-M-v, C-M-S-v)
-        C-u o, C-u v .. kill quick-visited buffer (restores normal scrolling)
-        X ............. execute selected file
-        C-u X.......... execute selected file with arguments
-
-        + ............. create new directory
-        M-+ ........... create new empty file(s)
-        C ............. copy marked (or current) files and directories
-        R ............. rename marked (or current) files and directories
-        D ............. delete marked (or current) files and directories
-        S ............. soft-link selected file/directory to passive pane
-        Y ............. do relative soft-link of selected file in passive pane
-        H ............. hard-link selected file to passive pane
-        K ............. clone selected files and directories into passive pane
-        M-C ........... copy (using traditional dired-do-copy)
-        M-R ........... rename (using traditional dired-do-rename)
-        M-D ........... delete (using traditional dired-do-delete)
-        M-S............ soft-link (using traditional dired-do-symlink)
-        M-Y............ do relative soft-link (traditional dired-do-relsymlink)
-        M-H............ hard-link selected file/directory (dired-do-hardlink)
-        A ............. search marked files for regular expression
-        Q ............. perform query-replace-regexp on marked files
-        C-c s ......... start a \"sticky\" interactive search in the current pane
-
-        M-a ........... move to beginning of current directory
-        M-e ........... move to end of current directory
-        M-y ........... go to previous directory in history
-        M-u ........... go to next directory in history
-        C-M-y ......... go to previous directory in history on passive pane
-        C-M-u ......... go to next directory in history on passive pane
-
-        g, C-c C-c .... refresh pane
-        s ............. sort entries (by name, number, size, time or extension)
-        r ............. reverse the order of entries in the active pane (sticky)
-        C-o ........... show/hide hidden files (requires dired-omit-mode)
-        C-Backspace ... hide/show file attributes in pane
-        C-c Backspace . hide/show file attributes in pane (console compatible)
-        y ............. show file type / size of selected files and directories.
-        M-l ........... truncate/continue long lines in pane
-        C-c v ......... put current panel in VIRTUAL mode
-        C-c C-v ....... create new pure VIRTUAL buffer
-        C-c C-w ....... browse directory tree using w3m
-
-        M-t ........... transpose panes
-        M-o ........... synchronize panes
-        C-c C-s ....... change panes layout (vertical/horizontal/top-only)
-        [ ............. enlarges the right pane by 5 columns
-        ] ............. enlarges the left pane by 5 columns
-        } ............. enlarges the panes vertically by 1 row
-        C-} ........... enlarges the panes vertically as much as it can
-        C-c } ......... enlarges the panes vertically as much as it can
-        { ............. shrinks the panes vertically by 1 row
-        C-{ ........... shrinks the panes vertically as much as it can
-        C-c { ......... shrinks the panes vertically as much as it can
-        \\ ............. restores the size of all windows back to «normal»
-        C-c C-z ....... enable/disable synchronized navigation
-
-        C-= ........... smart compare files (ediff)
-        C-c = ......... smart compare files (console compatible)
-        = ............. fast smart compare files (plain diff)
-        C-M-= ......... compare panes
-        C-x = ......... compare panes (console compatible)
-
-        C-c C-f ....... execute Find-dired in Sunrise VIRTUAL mode
-        C-c C-n ....... execute find-Name-dired in Sunrise VIRTUAL mode
-        C-c C-g ....... execute find-Grep-dired in Sunrise VIRTUAL mode
-        C-u C-c C-g ... execute find-Grep-dired with additional grep options
-        C-c C-l ....... execute Locate in Sunrise VIRTUAL mode
-        C-c C-r ....... browse list of Recently visited files (requires recentf)
-        C-c C-c ....... [after find, locate or recent] dismiss virtual buffer
-        C-c / ......... narrow the contents of current pane using fuzzy matching
-        C-c b ......... partial Branch view of selected items in current pane
-        C-c p ......... Prune paths matching regular expression from current pane
-        ; ............. follow file (go to same directory as selected file)
-        M-; ........... follow file in passive pane
-        C-M-o ......... follow a projection of current directory in passive pane
-
-        C-> ........... save named checkpoint (a.k.a. \"bookmark panes\")
-        C-c > ......... save named checkpoint (console compatible)
-        C-.    ........ restore named checkpoint
-        C-c .  ........ restore named checkpoint
-
-        C-x C-q ....... put pane in Editable Dired mode (commit with C-c C-c)
-        @! ............ fast backup files (not dirs!), each to [filename].bak
-
-        C-c t ......... open new terminal or switch to already open one
-        C-c T ......... open terminal AND/OR change directory to current
-        C-c C-t ....... open always a new terminal in current directory
-        C-c M-t ....... open a new terminal using an alternative shell program
-        q, C-x k ...... quit Sunrise Commander, restore previous window setup
-        M-q ........... quit Sunrise Commander, don't restore previous windows
-
-Additionally, the following traditional commander-style keybindings are provided
-\(these may be disabled by customizing the `sr-use-commander-keys' option):
-
-        F2 ............ go to directory
-        F3 ............ quick visit selected file
-        F4 ............ visit selected file
-        F5 ............ copy marked (or current) files and directories
-        F6 ............ rename marked (or current) files and directories
-        F7 ............ create new directory
-        F8 ............ delete marked (or current) files and directories
-        F10 ........... quit Sunrise Commander
-        C-F3 .......... sort contents of current pane by name
-        C-F4 .......... sort contents of current pane by extension
-        C-F5 .......... sort contents of current pane by time
-        C-F6 .......... sort contents of current pane by size
-        C-F7 .......... sort contents of current pane numerically
-        S-F7 .......... soft-link selected file/directory to passive pane
-        Insert ........ mark file
-        C-PgUp ........ go to parent directory
-
-Any other dired keybinding (not overridden by any of the above) can be used in
-Sunrise, like G for changing group, M for changing mode and so on.
-
-Some more bindings are available in terminals opened using any of the Sunrise
-functions (i.e. one of: C-c t, C-c T, C-c C-t, C-c M-t):
-
-        C-c Tab ....... switch focus to the active pane
-        C-c t ......... cycle through all currently open terminals
-        C-c T ......... cd to the directory in the active pane
-        C-c C-t ....... open new terminal, cd to directory in the active pane
-        C-c ; ......... follow the current directory in the active pane
-        C-c { ......... shrink the panes vertically as much as possible
-        C-c } ......... enlarge the panes vertically as much as possible
-        C-c \\ ......... restore the size of all windows back to «normal»
-        C-c C-j ....... put terminal in line mode
-        C-c C-k ....... put terminal back in char mode
-
-The following bindings are available only in line mode (eshell is considered to
-be *always* in line mode):
-
-        M-<up>, M-P ... move cursor up in the active pane
-        M-<down>, M-N . move cursor down in the active pane
-        M-Return ...... visit selected file/directory in the active pane
-        M-J ........... go to parent directory in the active pane
-        M-G ........... refresh active pane
-        M-Tab ......... switch to passive pane (without leaving the terminal)
-        M-M ........... mark selected file/directory in the active pane
-        M-Backspace ... unmark previous file/directory in the active pane
-        M-U ........... remove all marks from the active pane
-        C-Tab ......... switch focus to the active pane
-
-In a terminal in line mode the following substitutions are also performed
-automatically:
-
-       %f - expands to the currently selected file in the left pane
-       %F - expands to the currently selected file in the right pane
-       %m - expands to the list of paths of all marked files in the left pane
-       %M - expands to the list of paths of all marked files in the right pane
-       %n - expands to the list of names of all marked files in the left pane
-       %N - expands to the list of names of all marked files in the right pane
-       %d - expands to the current directory in the left pane
-       %D - expands to the current directory in the right pane
-       %a - expands to the list of paths of all marked files in the active pane
-       %A - expands to the current directory in the active pane
-       %p - expands to the list of paths of all marked files in the passive pane
-       %P - expands to the current directory in the passive pane
-       %% - inserts a single % sign.
-"
-  :group 'sunrise
-  (unless (string-match "\\(Sunrise\\)" (buffer-name))
-    (rename-buffer (concat (buffer-name) " (Sunrise)") t))
-  (set-keymap-parent sr-mode-map dired-mode-map)
-  (sr-highlight)
-  (dired-omit-mode dired-omit-mode)
-
-  (make-local-variable 'truncate-partial-width-windows)
-  (setq truncate-partial-width-windows (sr-truncate-v t))
-
-  (set (make-local-variable 'buffer-read-only) t)
-  (set (make-local-variable 'dired-header-face) 'sr-passive-path-face)
-  (set (make-local-variable 'dired-recursive-deletes) 'top)
-  (set (make-local-variable 'truncate-lines) nil)
-  (set (make-local-variable 'desktop-save-buffer) 'sr-desktop-save-buffer)
-  (set (make-local-variable 'revert-buffer-function) 'sr-revert-buffer)
-  (set (make-local-variable 'buffer-quit-function) 'sr-quit)
-  (set (make-local-variable 'sr-show-file-attributes) sr-show-file-attributes)
-  (set (make-local-variable 'hl-line-sticky-flag) nil)
-  (hl-line-mode 1)
-)
-
-;;;###autoload
-(define-derived-mode sr-virtual-mode dired-virtual-mode "Sunrise VIRTUAL"
-  "Sunrise Commander Virtual Mode. Useful for reusing find and locate results."
-  :group 'sunrise
-  (set-keymap-parent sr-virtual-mode-map sr-mode-map)
-  (sr-highlight)
-  (enriched-mode -1)
-
-  (make-local-variable 'truncate-partial-width-windows)
-  (setq truncate-partial-width-windows (sr-truncate-v t))
-
-  (set (make-local-variable 'buffer-read-only) t)
-  (set (make-local-variable 'dired-header-face) 'sr-passive-path-face)
-  (set (make-local-variable 'truncate-lines) nil)
-  (set (make-local-variable 'desktop-save-buffer) 'sr-desktop-save-buffer)
-  (set (make-local-variable 'revert-buffer-function) 'sr-revert-buffer)
-  (set (make-local-variable 'buffer-quit-function) 'sr-quit)
-  (set (make-local-variable 'sr-show-file-attributes) sr-show-file-attributes)
-  (set (make-local-variable 'hl-line-sticky-flag) nil)
-  (hl-line-mode 1)
-
-  (define-key sr-virtual-mode-map "\C-c\C-c" 'sr-virtual-dismiss))
-
-(defmacro sr-within (dir form)
-  "Evaluate FORM in Sunrise context."
-  `(unwind-protect
-       (progn
-         (setq sr-dired-directory
-               (file-name-as-directory (abbreviate-file-name ,dir)))
-         (ad-activate 'dired-find-buffer-nocreate)
-         ,form)
-     (ad-deactivate 'dired-find-buffer-nocreate)
-     (setq sr-dired-directory "")))
-
-(defmacro sr-save-aspect (&rest body)
-  "Restore omit mode, hidden attributes and point after a directory transition."
-  `(let ((inhibit-read-only t)
-         (omit (or dired-omit-mode -1))
-         (attrs (eval 'sr-show-file-attributes))
-         (path-faces sr-current-path-faces))
-     ,@body
-     (dired-omit-mode omit)
-     (if path-faces
-         (setq sr-current-path-faces path-faces))
-     (if (string= "NUMBER" (get sr-selected-window 'sorting-order))
-         (sr-sort-by-operation 'sr-numerical-sort-op))
-     (if (get sr-selected-window 'sorting-reverse)
-         (sr-reverse-pane))
-     (setq sr-show-file-attributes attrs)
-     (sr-display-attributes (point-min) (point-max) sr-show-file-attributes)
-     (sr-restore-point-if-same-buffer)))
-
-(defmacro sr-alternate-buffer (form)
-  "Execute FORM in a new buffer, after killing the previous one."
-  `(let ((dispose nil))
-     (unless (or (not (or dired-directory (eq major-mode 'sr-tree-mode)))
-                 (eq sr-left-buffer sr-right-buffer))
-       (setq dispose (current-buffer)))
-     ,form
-     (setq sr-this-directory default-directory)
-     (sr-keep-buffer)
-     (sr-highlight)
-     (when (and sr-kill-unused-buffers (buffer-live-p dispose))
-       (with-current-buffer dispose
-         (bury-buffer)
-         (set-buffer-modified-p nil)
-         (unless (kill-buffer dispose)
-           (kill-local-variable 'sr-current-path-faces))))))
-
-(defmacro sr-in-other (form)
-  "Execute FORM in the context of the passive pane.
-Helper macro for passive & synchronized navigation."
-  `(let ((home sr-selected-window))
-     (let ((sr-inhibit-highlight t))
-       (if sr-synchronized ,form)
-       (sr-change-window)
-       (condition-case description
-           ,form
-         (error (message (cadr description)))))
-     (if (not sr-running)
-         (sr-select-window home)
-       (run-hooks 'sr-refresh-hook)
-       (sr-change-window))))
-
-(defmacro sr-silently (&rest body)
-  "Inhibit calls to `message' in BODY."
-  `(letf (((symbol-function 'message) (lambda (_msg &rest _args) (ignore))))
-     ,@body))
-
-(eval-and-compile
-  (defun sr-symbol (side type)
-    "Synthesize Sunrise symbols (`sr-left-buffer', `sr-right-window', etc.)."
-    (intern (concat "sr-" (symbol-name side) "-" (symbol-name type)))))
-
-(defun sr-dired-mode ()
-  "Set Sunrise mode in every Dired buffer opened in Sunrise (called in a hook)."
-  (if (and sr-running
-           (eq (selected-frame) sr-current-frame)
-           (sr-equal-dirs dired-directory default-directory)
-           (not (eq major-mode 'sr-mode)))
-      (let ((dired-listing-switches dired-listing-switches)
-            (sorting-options (or (get sr-selected-window 'sorting-options) "")))
-        (unless (and (featurep 'tramp)
-                     (string-match tramp-file-name-regexp default-directory))
-          (setq dired-listing-switches
-                (concat sr-listing-switches sorting-options)))
-        (sr-mode)
-        (dired-unadvertise dired-directory))))
-(add-hook 'dired-before-readin-hook 'sr-dired-mode)
-
-(defun sr-bookmark-jump ()
-  "Handle panes opened from bookmarks in Sunrise."
-  (when (and sr-running
-             (memq (selected-window) (list sr-left-window sr-right-window)))
-    (let ((last-buf (symbol-value (sr-symbol sr-selected-window 'buffer))))
-      (setq dired-omit-mode (with-current-buffer last-buf dired-omit-mode))
-      (setq sr-this-directory default-directory)
-      (if (sr-equal-dirs sr-this-directory sr-other-directory)
-          (sr-synchronize-panes t)
-        (revert-buffer))
-      (sr-keep-buffer)
-      (unless (memq last-buf (list (current-buffer) (sr-other 'buffer)))
-        (kill-buffer last-buf)))))
-(add-hook 'bookmark-after-jump-hook 'sr-bookmark-jump)
-
-(defun sr-virtualize-pane ()
-  "Put the current normal view in VIRTUAL mode."
-  (interactive)
-  (when (eq major-mode 'sr-mode)
-    (let ((focus (dired-get-filename 'verbatim t)))
-      (sr-save-aspect
-       (when (eq sr-left-buffer sr-right-buffer)
-         (dired default-directory)
-         (sr-keep-buffer))
-       (sr-virtual-mode))
-      (if focus (sr-focus-filename focus)))))
-
-(defun sr-virtual-dismiss ()
-  "Restore normal pane view in Sunrise VIRTUAL mode."
-  (interactive)
-  (when (eq major-mode 'sr-virtual-mode)
-    (let ((focus (dired-get-filename 'verbatim t)))
-      (sr-process-kill)
-      (sr-save-aspect
-       (sr-alternate-buffer (sr-goto-dir sr-this-directory))
-       (if focus (sr-focus-filename focus))
-       (revert-buffer)))))
-
-(defun sr-select-window (side)
-  "Select/highlight the given Sunrise window (right or left)."
-  (select-window (symbol-value (sr-symbol side 'window)))
-  (setq sr-selected-window side)
-  (setq sr-this-directory default-directory)
-  (sr-highlight))
-
-(defun sr-viewer-window ()
-  "Return an active window that can be used as the viewer."
-  (if (or (memq major-mode '(sr-mode sr-virtual-mode sr-tree-mode))
-          (memq (current-buffer) (list sr-left-buffer sr-right-buffer)))
-      (let ((current-window (selected-window)) (target-window))
-        (dotimes (_times 2)
-          (setq current-window (next-window current-window))
-          (unless (memq current-window (list sr-left-window sr-right-window))
-            (setq target-window current-window)))
-        target-window)
-    (selected-window)))
-
-(defun sr-select-viewer-window (&optional force-setup)
-  "Select a window that is not a Sunrise pane.
-If no suitable active window can be found and FORCE-SETUP is set,
-calls the function `sr-setup-windows' and tries once again."
-  (interactive "p")
-  (let ((viewer (sr-viewer-window)))
-    (if (memq major-mode '(sr-mode sr-virtual-mode sr-tree-mode))
-        (hl-line-mode 1))
-    (if viewer
-        (select-window viewer)
-      (when force-setup
-        (sr-setup-windows)
-        (select-window (sr-viewer-window))))))
-
-(defun sr-backup-buffer ()
-  "Create a backup copy of the current buffer.
-Used as a cache during revert operations."
-  (if (buffer-live-p sr-backup-buffer) (sr-kill-backup-buffer))
-  (let ((buf (current-buffer)))
-    (setq sr-backup-buffer (generate-new-buffer "*Sunrise Backup*"))
-    (with-current-buffer sr-backup-buffer
-      (insert-buffer-substring buf))
-    (run-hooks 'sr-refresh-hook)))
-
-(defun sr-kill-backup-buffer ()
-  "Kill the backup buffer associated to the current one, if there is any."
-  (when (buffer-live-p sr-backup-buffer)
-    (kill-buffer sr-backup-buffer)
-    (setq sr-backup-buffer nil)))
-(add-hook 'kill-buffer-hook       'sr-kill-backup-buffer)
-(add-hook 'change-major-mode-hook 'sr-kill-backup-buffer)
-
-(add-to-list 'enriched-translations '(invisible (t "x-invisible")))
-(defun sr-enrich-buffer ()
-  "Activate `enriched-mode' before saving a Sunrise buffer to a file.
-This is done so all its dired-filename attributes are kept in the file."
-  (if (memq major-mode '(sr-mode sr-virtual-mode))
-      (enriched-mode 1)))
-(add-hook 'before-save-hook 'sr-enrich-buffer)
-
-(defun sr-extend-with (extension &optional filename)
-  "Try to enhance Sunrise with EXTENSION (argument must be a symbol).
-An extension can be loaded from optional FILENAME. If found, the extension is
-immediately loaded, but only if `sr-autoload-extensions' is not nil."
-  (when sr-autoload-extensions
-    (require extension filename t)))
-
-(defadvice dired-find-buffer-nocreate
-  (before sr-advice-findbuffer (dirname &optional mode))
-  "A hack to avoid some Dired mode quirks in the Sunrise Commander."
-  (if (sr-equal-dirs sr-dired-directory dirname)
-      (setq mode 'sr-mode)))
-;; ^--- activated by sr-within macro
-
-(defadvice dired-dwim-target-directory
-  (around sr-advice-dwim-target ())
-  "Tweak the target directory guessing mechanism when Sunrise Commander is on."
-  (if (and sr-running (eq (selected-frame) sr-current-frame))
-      (setq ad-return-value sr-other-directory)
-    ad-do-it))
-(ad-activate 'dired-dwim-target-directory)
-
-(defadvice other-window
-  (around sr-advice-other-window (count &optional all-frames))
-  "Select the correct Sunrise Commander pane when switching from other windows."
-  (if (or (not sr-running) sr-ediff-on)
-      ad-do-it
-    (let ((from (selected-window)))
-      ad-do-it
-      (unless (or sr-traditional-other-window
-                  (memq from (list sr-left-window sr-right-window)))
-        ;; switching from outside
-        (sr-select-window sr-selected-window))
-      (with-no-warnings
-        (when (eq (selected-window) (sr-other 'window))
-          ;; switching from the other pane
-          (sr-change-window))))))
-(ad-activate 'other-window)
-
-(defadvice use-hard-newlines
-  (around sr-advice-use-hard-newlines (&optional arg insert))
-  "Stop asking if I want hard lines the in Sunrise Commander, just guess."
-  (if (memq major-mode '(sr-mode sr-virtual-mode))
-      (let ((inhibit-read-only t))
-        (setq insert 'guess)
-        ad-do-it)
-    ad-do-it))
-(ad-activate 'use-hard-newlines)
-
-(defadvice dired-insert-set-properties
-  (after sr-advice-dired-insert-set-properties (beg end))
-  "Manage hidden attributes in files added externally (e.g. from find-dired) to
-the Sunrise Commander."
-  (when (memq major-mode '(sr-mode sr-virtual-mode))
-    (with-no-warnings
-      (sr-display-attributes beg end sr-show-file-attributes))))
-(ad-activate 'dired-insert-set-properties)
-
-;;; ============================================================================
-;;; Sunrise Commander keybindings:
-
-(define-key sr-mode-map "\C-m"        'sr-advertised-find-file)
-(define-key sr-mode-map "f"           'sr-advertised-find-file)
-(define-key sr-mode-map "X"           'sr-advertised-execute-file)
-(define-key sr-mode-map "o"           'sr-quick-view)
-(define-key sr-mode-map "v"           'sr-quick-view)
-(define-key sr-mode-map "/"           'sr-goto-dir)
-(define-key sr-mode-map "j"           'sr-goto-dir)
-(define-key sr-mode-map "^"           'sr-dired-prev-subdir)
-(define-key sr-mode-map "J"           'sr-dired-prev-subdir)
-(define-key sr-mode-map ";"           'sr-follow-file)
-(define-key sr-mode-map "\M-t"        'sr-transpose-panes)
-(define-key sr-mode-map "\M-o"        'sr-synchronize-panes)
-(define-key sr-mode-map "\C-\M-o"     'sr-project-path)
-(define-key sr-mode-map "\M-y"        'sr-history-prev)
-(define-key sr-mode-map "\M-u"        'sr-history-next)
-(define-key sr-mode-map "\C-c>"       'sr-checkpoint-save)
-(define-key sr-mode-map "\C-c."       'sr-checkpoint-restore)
-(define-key sr-mode-map "\C-c\C-z"    'sr-sync)
-(define-key sr-mode-map "\C-c\C-c"    'revert-buffer)
-
-(define-key sr-mode-map "\t"          'sr-change-window)
-(define-key sr-mode-map "\C-c\t"      'sr-select-viewer-window)
-(define-key sr-mode-map "\M-a"        'sr-beginning-of-buffer)
-(define-key sr-mode-map "\M-e"        'sr-end-of-buffer)
-(define-key sr-mode-map "\C-c\C-s"    'sr-split-toggle)
-(define-key sr-mode-map "]"           'sr-enlarge-left-pane)
-(define-key sr-mode-map "["           'sr-enlarge-right-pane)
-(define-key sr-mode-map "}"           'sr-enlarge-panes)
-(define-key sr-mode-map "{"           'sr-shrink-panes)
-(define-key sr-mode-map "\\"          'sr-lock-panes)
-(define-key sr-mode-map "\C-c}"       'sr-max-lock-panes)
-(define-key sr-mode-map "\C-c{"       'sr-min-lock-panes)
-(define-key sr-mode-map "\C-o"        'dired-omit-mode)
-(define-key sr-mode-map "b"           'sr-browse-file)
-(define-key sr-mode-map "\C-c\C-w"    'sr-browse-pane)
-(define-key sr-mode-map "\C-c\d"      'sr-toggle-attributes)
-(define-key sr-mode-map "\M-l"        'sr-toggle-truncate-lines)
-(define-key sr-mode-map "s"           'sr-interactive-sort)
-(define-key sr-mode-map "r"           'sr-reverse-pane)
-(define-key sr-mode-map "\C-e"        'sr-scroll-up)
-(define-key sr-mode-map "\C-y"        'sr-scroll-down)
-(define-key sr-mode-map " "           'sr-scroll-quick-view)
-(define-key sr-mode-map "\M- "        'sr-scroll-quick-view-down)
-(define-key sr-mode-map [?\S- ]       'sr-scroll-quick-view-down)
-
-(define-key sr-mode-map "C"           'sr-do-copy)
-(define-key sr-mode-map "K"           'sr-do-clone)
-(define-key sr-mode-map "R"           'sr-do-rename)
-(define-key sr-mode-map "D"           'sr-do-delete)
-(define-key sr-mode-map "x"           'sr-do-flagged-delete)
-(define-key sr-mode-map "S"           'sr-do-symlink)
-(define-key sr-mode-map "Y"           'sr-do-relsymlink)
-(define-key sr-mode-map "H"           'sr-do-hardlink)
-(define-key sr-mode-map "\M-C"        'dired-do-copy)
-(define-key sr-mode-map "\M-R"        'dired-do-rename)
-(define-key sr-mode-map "\M-D"        'dired-do-delete)
-(define-key sr-mode-map "\M-S"        'dired-do-symlink)
-(define-key sr-mode-map "\M-Y"        'dired-do-relsymlink)
-(define-key sr-mode-map "\M-H"        'dired-do-hardlink)
-(define-key sr-mode-map "\C-x\C-q"    'sr-editable-pane)
-(define-key sr-mode-map "@"           'sr-fast-backup-files)
-(define-key sr-mode-map "\M-+"        'sr-create-files)
-
-(define-key sr-mode-map "="           'sr-diff)
-(define-key sr-mode-map "\C-c="       'sr-ediff)
-(define-key sr-mode-map "\C-x="       'sr-compare-panes)
-
-(define-key sr-mode-map "\C-c\C-f"    'sr-find)
-(define-key sr-mode-map "\C-c\C-n"    'sr-find-name)
-(define-key sr-mode-map "\C-c\C-g"    'sr-find-grep)
-(define-key sr-mode-map "\C-cb"       'sr-flatten-branch)
-(define-key sr-mode-map "\C-cp"       'sr-prune-paths)
-(define-key sr-mode-map "\C-c\C-l"    'sr-locate)
-(define-key sr-mode-map "\C-c/"       'sr-fuzzy-narrow)
-(define-key sr-mode-map "\C-c\C-r"    'sr-recent-files)
-(define-key sr-mode-map "\C-c\C-d"    'sr-recent-directories)
-(define-key sr-mode-map "\C-cv"       'sr-virtualize-pane)
-(define-key sr-mode-map "\C-c\C-v"    'sr-pure-virtual)
-(define-key sr-mode-map "Q"           'sr-do-query-replace-regexp)
-(define-key sr-mode-map "F"           'sr-do-find-marked-files)
-(define-key sr-mode-map "A"           'sr-do-search)
-(define-key sr-mode-map "\C-cs"       'sr-sticky-isearch-forward)
-(define-key sr-mode-map "\C-cr"       'sr-sticky-isearch-backward)
-(define-key sr-mode-map "\C-x\C-f"    'sr-find-file)
-(define-key sr-mode-map "y"           'sr-show-files-info)
-
-(define-key sr-mode-map "\M-n"        'sr-next-line-other)
-(define-key sr-mode-map [M-down]      'sr-next-line-other)
-(define-key sr-mode-map [A-down]      'sr-next-line-other)
-(define-key sr-mode-map "\M-p"        'sr-prev-line-other)
-(define-key sr-mode-map [M-up]        'sr-prev-line-other)
-(define-key sr-mode-map [A-up]        'sr-prev-line-other)
-(define-key sr-mode-map "\M-j"        'sr-goto-dir-other)
-(define-key sr-mode-map "\M-\C-m"     'sr-advertised-find-file-other)
-(define-key sr-mode-map "\M-f"        'sr-advertised-find-file-other)
-(define-key sr-mode-map "\C-c\C-m"    'sr-advertised-find-file-other)
-(define-key sr-mode-map "\M-^"