6

From some newer version of Emacs (I currently on 24.5.1) after some operation *vc-dir* buffer begin to show ignored files.

I specially craft .hgignore to make list of hg status short. But Emacs vc-mode doesn't respect my preference.

Is it possible to ignore ignored files?

To reproduce:

  • open *vc-dir*
  • modify file
  • undo changes on file from *vc-dir*
  • refresh *vc-dir* content

I made wrapper to diagnose problem:

#!/bin/sh
echo hg "$@" >> ~/tmp/hg.log
/usr/bin/hg "$@"

From above instruction steps I get log:

root       # here I press C-x v d
id -b
id -t
status -C ./   # below I edit and save file
hg --config alias.status=status --config defaults.status= status -A hg.rst
hg --config alias.status=status --config defaults.status= status -A hg.rst
hg parent --template {rev} hg.rst
hg --config alias.status=status --config defaults.status= status -A hg.rst
hg --config alias.status=status --config defaults.status= status -A hg.rst
hg diff hg.rst       # <== revert file in *vc-dir* by C-x v u
hg revert hg.rst
hg --config alias.status=status --config defaults.status= status -A hg.rst
hg root            # <== here I press g
hg id -b
hg id -t
hg status -C ./
hg status -mardui -C hg.rst ./

Last command include -i option which cause issue. Sources have:

$ grep -R -n mardu
lisp/vc/vc-hg.el:640:         (concat "-mardu" (if files "i"))

which is:

(defun vc-hg-dir-status-files (dir files update-function)
  (apply 'vc-hg-command (current-buffer) 'async dir "status"
         (concat "-mardu" (if files "i"))
         "-C" files)
  (vc-run-delayed
    (vc-hg-after-dir-status update-function)))

lisp/vc/vc.el state that:

;; - dir-status-files (dir files update-function)
;;   If FILES is non-nil, this function should report on all requested
;;   files, including up-to-date or ignored files.

UPDATE I open bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22003

I receive recommendation to type x to clear unnecessary entry.

gavenkoa
  • 3,352
  • 19
  • 36

2 Answers2

2

I finally came around to solving this problem. The following code uses ‘vc-exec-after’ to be compatible with Emacs 23.x.

With the customizable command ‘vcx-dir-hide-states’, mapped to ‘X’ in *vc-dir* buffers:

(require 'vc-dir)
(require 'vc-hooks)

(defvar vcx-dir-hide-states-list
  '(up-to-date ignored unregistered)
  "VC states of entries to be hidden after VC directory refresh.")

(defun vcx-dir-hide-states ()
  "Hide VC directory entires for states from ‘vcx-dir-hide-states-list’."
  (interactive)
  (when (derived-mode-p 'vc-dir-mode)
    (dolist (state vcx-dir-hide-states-list)
      (vc-dir-hide-state state))
    ))

(define-key vc-dir-mode-map "X" 'vcx-dir-hide-states)

the command ‘vcx-dir-refresh’

(defun vcx-dir-refresh (&optional full)
  "Refresh VC directory, if in ‘vc-dir-mode’ or call ‘vc-dir’ interactively.
Automatically hides entries accoridng to ‘vcx-dir-hide-states-list’.
With prefix arg, the regular ‘revert-buffer’ is called."
  (interactive "P")
  (if (derived-mode-p 'vc-dir-mode)
      (revert-buffer)
    (call-interactively 'vc-dir))
  (unless full
    (let ((vcx-dir-buffer (buffer-name (current-buffer))))
      (with-current-buffer
      (or (and (buffer-live-p vc-dir-process-buffer)
           vc-dir-process-buffer)
          (current-buffer))
    (vc-exec-after
     `(let ((vcx-dir-buffer ,vcx-dir-buffer))
        (with-current-buffer vcx-dir-buffer
          (vcx-dir-hide-states))))))))

can be used to replace ‘C-x v d’

(define-key vc-prefix-map "d" 'vcx-dir-refresh)

and ‘g’ in ‘vc-dir-mode’:

(define-key vc-dir-mode-map "g" 'vcx-dir-refresh)
wolfmanx
  • 131
  • 4
1

Every time ignored files show up, you move your cursor (not mouse pointer :D) to a line with an ignored file, and then type C-u x. That makes all the files in that state (ignored) disappear. Until an update of the buffer.

As far as I could find out, they for some unfathomable reason (tried to find it, found some mails which didn't seem to make any sense) decided to... have you manually redo this.

I also found some mails from Emacs 25 development which mention it, and... I couldn't tell what the proposed and/or implemented solution was. We'll have to wait for 25 and see.

Drew
  • 75,699
  • 9
  • 109
  • 225
  • Consider providing links to the relevant mailing-list mails. You can locate them at http://lists.gnu.org/archive/html/emacs-devel/. – Drew Jan 26 '16 at 02:18
  • 1
    @Drew After asking question here I have opened bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22003 Upstream doesn't think that I am right. I have no time to provide patch or debate. – gavenkoa Jan 26 '16 at 17:36