4

I have this in my init.el file:

(use-package dired
  :init
  (progn
    ;; Details toggling is bound to "(" in `dired-mode' by default
    (setq diredp-hide-details-initially-flag nil))  
  :config
  (use-package dired+
    :ensure t)
  (add-hook 'dired-mode-hook 'auto-revert-mode)
  (add-hook 'dired-mode-hook  (lambda () (setq auto-revert-verbose nil)))
  )

Running Emacs with no window mode emacs -nw and when moving cursors I get "change ownership" instead when in directory view. Removing the code related to Dired+ solved the problem. Any pointers to why that happens? If no workaround, is there a way to disable Dired+ mode only when running emacs -nw

6
  • 1. I can't repro the problem from a virgin Emacs. Could you please try to repro the problem using emacs -nw -Q and explicitly requiring dired+.el (i.e., not using use-package), and send it along to me by email (see file header).
    – Drew
    Commented Jun 28, 2017 at 22:08
  • 1
    2. I don't know about use-package, but if you explicitly put dired+.el in your load-path and then put (require 'dired+) in your init file, you can make the latter conditional: (when (display-graphic-p) (require 'dired+.el)) will require it only when Emacs is not in terminal mode.
    – Drew
    Commented Jun 28, 2017 at 22:10
  • 1. (continued) Also, please describe when the hang occurs. Does it occur when a revert occurs? When Dired mode is set up (a directory is visited)? When?
    – Drew
    Commented Jun 28, 2017 at 22:15
  • This worked for me (when (display-graphic-p) (use-package dired+ :ensure t)). Drew, if I don't specify a file to open, I have it setup to open in dired mode, so it hangs directly. No reverting or anything, I can't move the cursor. I have not tried with (require) since all my init file is setup using use-package. Will see if I can perform the experiment.
    – SFbay007
    Commented Jun 28, 2017 at 23:14
  • 1
    I still see the problem when starting with vanilla emacs and only (require 'dired+) in init.el. There is no issue when requiring all three other files (dired, dired-x, dired-aux). I also found that it is not an actual hang, but cursor not moving with arrows and hitting enter will ask to change owner of the file at point.
    – SFbay007
    Commented Jun 29, 2017 at 0:28

2 Answers 2

5

dired+ is binding shortcuts that conflict with the character sequences that your terminal is sending when you hit the arrow keys. Something very similar happened to me. Here is how I handled it:

(use package dired+ :config
    (define-key dired-mode-map [(meta shift ?o)] nil))

When I pressed an arrow key, dired+'s key-binding for 'diredp-chmod-this-file was erroneously triggered, until I unbound it like above. This happened for me in both linux and Mac OS X terminal emulators, but I'm not sure if your terminal emulator is sending the exact same sequence; if not, you'll have to adjust the above. To see what a character sequence really is, press Control-h c and then, say, an arrow key, to have emacs print out what key it is receiving based upon that character sequence.

4
  • Yup, this same setup solved the problem.
    – SFbay007
    Commented Jun 29, 2017 at 5:12
  • Great. The missing info came from the OP's last comment - about what action (pressing cursor keys) led to the problem. OP: Please put that info in the question, so it is complete. (Comments can be deleted at any time.) Thx.
    – Drew
    Commented Jun 29, 2017 at 13:52
  • Issue updated. Thanks Drew.
    – SFbay007
    Commented Jun 29, 2017 at 20:39
  • See also this node in the Org manual: (info "(org) TTY keys") - same problem.
    – Drew
    Commented Jun 30, 2017 at 13:55
2

Based on the info from this question and the answer by @InHarmsWay, I've updated Dired+ to add this user option, whose value defaults to t:

diredp-bind-problematic-terminal-keys is a variable defined in dired+.el.

Its value is t

Documentation:

Non-nil means bind some keys that might not work in terminal mode.

This applies to keys that use modifiers Meta and Shift together. If you use Emacs in terminal mode (emacs -nw) and your terminal does not support the use of such keys then customize this option to nil.

The problematic keys (for some terminals) are these:

`M-M'       (aka `M-S-m')       - `diredp-chmod-this-file'
`M-O'       (aka `M-S-o')       - `diredp-chown-this-file'
`M-T'       (aka `M-S-t')       - `diredp-touch-this-file'
`C-M-B'     (aka `C-M-S-b')     - `diredp-do-bookmark-in-bookmark-file'
`C-M-G'     (aka `C-M-S-g')     - `diredp-chgrp-this-file'
`C-M-R'     (aka `C-M-S-r')     - `diredp-toggle-find-file-reuse-dir'
`C-M-T'     (aka `C-M-S-t')     - `dired-do-touch'
`M-+ M-B'   (aka `M-+ M-S-b')   - `diredp-do-bookmark-dirs-recursive'
`M-+ C-M-B' (aka `M-+ C-M-S-b') - `diredp-do-bookmark-in-bookmark-file-recursive'
`M-+ C-M-T' (aka `M-+ C-M-S-t') - `diredp-do-touch-recursive'
4
  • Thanks Drew. I checked list-packages but there is no update yet for Dired+, when is the update is expected to show up?
    – SFbay007
    Commented Jun 30, 2017 at 16:45
  • It is here now (I always upload to Emacs Wiki): emacswiki.org/emacs/download/dired%2b.el. It is then mirrored on MELPA up to a day later.
    – Drew
    Commented Jun 30, 2017 at 20:22
  • 1
    Drew, not sure how to apply this. I have added this setq : (setq diredp-bind-problematic-terminal-keys nil) but I keep getting the change owner when moving the cursor. I changed it's value to t and I still get same issue. Am I missing something?
    – SFbay007
    Commented Jun 30, 2017 at 21:30
  • Update: ok seems like I applied it at the wrong time in my use-package. Should be in init and not config block.
    – SFbay007
    Commented Jun 30, 2017 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.