bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16214: Consistency in dired-, occur-, and grep-mode


From: Tak Kunihiro
Subject: bug#16214: Consistency in dired-, occur-, and grep-mode
Date: Wed, 25 Dec 2013 08:15:39 +0900 (JST)

>> Assigning <RET> to (open-file-this-window) on occur/grep may loose
>> convenience, but helps new users because that behavior is similar to
>> following hyperlink in a web browser.
> 
> This behavior is similar to using History or Bookmarks window
> in a web browser.

I see the analogy of behavior <RET> in occur/grep as a sidebar. Then
dired is shown on the main window of the web browser watching
directory structure of a web server.

>> A. edit-buffer
>>   To avoid overwriting `e' in dired, it seems that `C-x C-q' is the
>>   second choice. Is `M-e' or `M-g e' better?
> 
> Adding a new key is not better because it will be incompatible
> with older versions.

How about to add `E' to edit buffer? It is close to `e' on occur, and
it seems that it is not used in any of dired/occur/wgrep yet.

>> D. open-file-this-window
>>   Other candidates besides <RET> would be something like `M-<RET>' or 'M-o'?
> 
> For a key to use for this-window you could look at `C-x C-b' (list-buffers)
> that binds the key `f' to `Buffer-menu-this-window'.

To assign `f' sounds very nice. Now proposed keys are summarized in
Table 1.




Table 1: A proposed mode, function, key-bind as-is, and key-bind
plus to have consistency between dired-, occur-, and grep.

|--------+----------------------------------------------+---------------+-----------|
| mode   | function                                     | key-as-is     | 
key-plus  |
|--------+----------------------------------------------+---------------+-----------|
| !      | A. edit-buffer (enable/finish/abort)         |               |       
    |
|--------+----------------------------------------------+---------------+-----------|
| wdired | (dired-toggle-read-only)                     | "C-x C-q"     | "E"   
    |
|        | (wdired-finish-edit)                         | "C-c C-c"     |       
    |
|        | (wdired-abort-changes)                       | "C-c C-k"     |       
    |
| occur  | (occur-edit-mode)                            | "e"           | "E"   
    |
|        | (occur-cease-edit)                           | "C-c C-c"     |       
    |
|        | ?                                            |               | "C-c 
C-k" |
| wgrep  | (wgrep-change-to-wgrep-mode)                 | "C-c C-p"     | "E"   
    |
|        | (wgrep-finish-edit)                          | "C-c C-c"     |       
    |
|        | (wgrep-abort-changes)                        | "C-c C-k"     |       
    |
|--------+----------------------------------------------+---------------+-----------|
| !      | B. open-file-other-window                    |               |       
    |
|--------+----------------------------------------------+---------------+-----------|
| dired  | (dired-find-file-other-window)               | "o"           |       
    |
| occur  | (occur-mode-goto-occurrence-other-window)    | <RET> and "o" |       
    |
| grep   | (compile-goto-error)                         | <RET>         | "o"   
    |
|--------+----------------------------------------------+---------------+-----------|
| !      | C. open-file-other-window-no-select          |               |       
    |
|--------+----------------------------------------------+---------------+-----------|
| dired  | (dired-display-file)                         | "C-o"         |       
    |
| occur  | (occur-mode-display-occurrence)              | "C-o"         |       
    |
| grep   | (grep-mode-display-occurrence); *1           |               | "C-o" 
    |
|--------+----------------------------------------------+---------------+-----------|
| !      | D. open-file-this-window                     |               |       
    |
|--------+----------------------------------------------+---------------+-----------|
| dired  | (dired-find-file)                            | <RET> and "f" |       
    |
| occur  | (occur-mode-goto-occurrence-this-window); *2 |               | "f"   
    |
| grep   | (compile-goto-error-this-window); *3         |               | "f"   
    |
|--------+----------------------------------------------+---------------+-----------|
| !      | Z. summary of function-assign-to-<RET>       |               |       
    |
|--------+----------------------------------------------+---------------+-----------|
| dired  | (dired-find-file)                            | <RET> and "f" |       
    |
| occur  | (occur-mode-goto-occurrence-other-window)    | <RET> and "o" |       
    |
| grep   | (compile-goto-error)                         | <RET>         | "o"   
    |
|--------+----------------------------------------------+---------------+-----------|

; *1
(defun grep-mode-display-occurrence ()
  (interactive)
  (let ((compilation-context-lines nil))
    (setq compilation-current-error (point))
    (next-error-no-select 0)))
; *2
(defun occur-mode-goto-occurrence-this-window ()
  "Go to the occurrence the current line describes, in this window."
  (interactive)
  (let ((pos (occur-mode-find-occurrence)))
    ;; (switch-to-buffer-other-window (marker-buffer pos))
    (switch-to-buffer (marker-buffer pos))
    (goto-char pos)
    (run-hooks 'occur-mode-find-occurrence-hook)))
; *3
; http://stackoverflow.com/questions/15814031
(defun compile-goto-error-this-window ()
  (interactive)
  (let ((display-buffer-overriding-action
         '(display-buffer-same-window
           (inhibit-same-window . nil)))
        (compilation-context-lines nil))
    (setq compilation-current-error (point))
    (compile-goto-error)))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]