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: Mon, 23 Dec 2013 20:34:59 +0900 (JST)

Thank you for the response.

> Inconsistency in opening in other window between Dired ("o") and
> occur/grep (<RET>) is a good inconsistency, because the primary
> purpose of occur/grep is to open files in other window, so
> more easy to type key <RET> is more suitable for occur/grep
> to open a file in other window.

I see. It sounds reasonable <RET> to be assigned to the primary
purpose. Following is when I think that to assign <RET> to
(open-file-this-window) is convenient.

  1. On edition of <file-a> in a single window, I feel like
     referring to sentences in a different file.
  2. (grep) something, then  *grep* pops up in (other-window).
  3. I will find a line in file-b; move cursor to the line on *grep*
  4. Hit <RET> then <file-b> pops up on the first window
  5. The buffer <file-a> disappears then I lost.

Now I know that I have to prepare the third window before hit <RET>!
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. After exercises, one can lean to
hit `o', which actually is more easy to type than <RET>. How do you
think about <RET> with considering new users?

Let me focus on dired/occur/grep with four functions (A-D) for
now. Proposed keys are summarized in Table 1.

  A. edit-buffer
  B. open-file-other-window
  C. open-file-other-window-no-select
  D. open-file-this-window
  
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?

B. open-file-other-window
  As you mentioned, add `o' to (compile-goto-error) will do it.

C. open-file-other-window-no-select
  Same thing, add `C-o' to something like (compilation-display-error)
  will do it.
  
D. open-file-this-window
  Other candidates besides <RET> would be something like `M-<RET>' or 'M-o'?


Tak


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"     |       
    |
|        | (wdired-finish-edit)                         | "C-c C-c"     |       
    |
|        | (wdired-abort-changes)                       | "C-c C-k"     |       
    |
| occur  | (occur-edit-mode)                            | "e"           | "C-x 
C-q" |
|        | (occur-cease-edit)                           | "C-c C-c"     |       
    |
|        | ?                                            |               | "C-c 
C-k" |
| wgrep  | (wgrep-change-to-wgrep-mode)                 | "C-c C-p"     | "C-x 
C-q" |
|        | (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>         | ?     
    |
| occur  | (occur-mode-goto-occurrence-this-window); *2 |               | ?     
    |
| grep   | (compile-goto-error-this-window); *3         |               | ?     
    |
|--------+----------------------------------------------+---------------+-----------|
| !      | Z. summary of function-assign-to-<RET>       |               |       
    |
|--------+----------------------------------------------+---------------+-----------|
| dired  | (dired-find-file)                            | <RET>         |       
    |
| 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]