Subject: 24.3.50; [PATCH] vc-ignore makes no sense
From: Andreas Politz <[email-masked]>
To: [email-masked]
Date: Wed, 30 Oct 2013 13:38:46 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

There are two problems with this function.

1. It uses vc-backend on the default-directory, which in turn uses
vc-registered.  But the return value of this function for directories
seems to be back end dependent.  E.g. in git it returns always nil for
directories, in bzr it seems to return t only if directory does not end
with a slash.  I am not sure which of these things needs to be fixed.
I suppose this function should do what it says and return t for
registered files (including directories).  But vc-ignore should also
work in the root directory, which technically is not registered.  So I
replaced it with vc-responsible-backend.

2. The interactive spec, when reading the documentation, makes no sense
to me.  I assume this is just an oversight.

3. The function should not have different abilities depending on whether
it was called interactively or not.

-ap

=== modified file 'lisp/vc/vc.el'
*** lisp/vc/vc.el	2013-10-25 02:33:42 +0000
--- lisp/vc/vc.el	2013-10-28 17:04:10 +0000
***************
*** 1350,1373 ****
    (let ((vc-handled-backends (list backend)))
      (call-interactively 'vc-register)))
  
! (defun vc-ignore (file &optional directory)
!   "Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
! FILE is a file wildcard.
! When called interactively and with a prefix argument, remove FILE
! from ignored files.
! When called from Lisp code, if DIRECTORY is non-nil, the
! repository to use will be deduced by DIRECTORY."
    (interactive
!    (list (read-file-name "The file to ignore: ")
  	 (completing-read
! 	  "The file to remove: "
  	  (vc-call-backend
! 	   (vc-backend default-directory)
! 	   'ignore-completion-table default-directory))))
    (let* ((directory (or directory default-directory))
! 	 (backend (vc-backend default-directory))
! 	 (remove current-prefix-arg))
!     (vc-call-backend backend 'ignore file directory remove)))
  
  (defun vc-default-ignore (backend file &optional directory remove)
    "Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
--- 1350,1382 ----
    (let ((vc-handled-backends (list backend)))
      (call-interactively 'vc-register)))
  
! (defun vc-ignore (file &optional directory remove-p)
!   "Ignore or remove FILE under the VCS of DIRECTORY.
! 
! If REMOVE-P if nil, FILE is a file wild-card to be ignored.
! Otherwise, remove FILE from the list of ignored files.
! 
! DIRECTORY defaults to `default-directory' and is used to
! determine the responsible VCS back-end.
! 
! Interactively, FILE is ignored, unless a prefix argument is
! given, which queries for a FILE to remove from the list of
! ignored files."
    (interactive
!    (list
!     (if (not current-prefix-arg)
!         (read-file-name "File to ignore: ")
        (completing-read
!        "File to remove: "
         (vc-call-backend
!         (or (vc-responsible-backend default-directory)
!             (error "Unknown back end"))
!         'ignore-completion-table default-directory)))
!     nil current-prefix-arg))
    (let* ((directory (or directory default-directory))
! 	 (backend (or (vc-responsible-backend default-directory)
!                       (error "Unknown back end"))))
!     (vc-call-backend backend 'ignore file directory remove-p)))
  
  (defun vc-default-ignore (backend file &optional directory remove)
    "Ignore FILE under the VCS of DIRECTORY (default is `default-directory').

In GNU Emacs 24.3.50.6 (x86_64-unknown-linux-gnu, GTK+ Version 2.20.1)
 of 2013-10-24 on luca
Bzr revision: 114430 [email-masked]
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
System Description:	Debian GNU/Linux 6.0.8 (squeeze)

Configured using:
 `configure -C'

Important settings:
  value of $LC_COLLATE: C
  value of $LC_MESSAGES: C
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  global-semanticdb-minor-mode: t
  global-semantic-decoration-mode: t
  global-semantic-idle-scheduler-mode: t
  desktop-save-mode: t
  mimo-mode: t
  pc-completion-mode: t
  ispell-track-input-method: t
  semantic-mode: t
  recentf-mode: t
  show-paren-mode: t
  window-numbering-mode: t
  shell-dirtrack-mode: t
  scroll-other-window-mode: t
  savehist-mode: t
  ekey-mode: t
  winner-mode: t
  eldoc-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-n C-n C-n C-n C-n C-n C-x o C-M-b C-M-SPC M-x f i 
x <return> M-x M-x <return> C-g C-x o C-l M-v C-l C-x 
o C-u C-x v = C-p C-e DEL <backspace> 2 9 M-h t r u 
n M-p M-p M-h C-k b z M-p DEL DEL DEL h h <backspace> 
t M-p DEL DEL C-r b z r C-r C-e <return> <return> C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-; b u C-; b r v c . p a t 
c h <return> C-x C-w / t m p <return> C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p M-f C-, g <return> C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-x k <return> 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-l C-n C-n C-n C-n C-n C-n C-n C-n 
C-x o C-n C-n C-n C-M-f C-M-f C-M-f C-M-f C-M-f C-M-f 
M-f M-f M-f M-f SPC b e M-f e d DEL DEL d M-q C-n C-r 
i s C-r C-r <return> C-n M-f C-M-f C-e C-n C-n C-M-b 
C-M-b C-M-b C-M-b a n d SPC M-b C-b , M-q M-f i DEL 
SPC i t M-q C-/ M-h M-b DEL DEL SPC M-q C-n C-M-a C-n 
M-m C-M-SPC M-x i s p e l l <return> a 1 1 C-n C-n 
C-n C-n C-n C-n C-p C-n C-e M-b DEL SPC DEL - C-n C-n 
C-n C-x C-s C-u C-x v = C-p C-p <return> <return> C-x 
o M-x r e p o r t - e m <tab> b u <return>

Recent messages:
Wrote /tmp/vc.patch
Mark set
Mark saved where search started
Undo!
Mark set [2 times]
Spell-checking region using aspell with en dictionary...done
Saving file /home/politza/src/emacs/override-redirect/lisp/vc/vc.el...
Wrote /home/politza/src/emacs/override-redirect/lisp/vc/vc.el
Finding changes in /home/politza/src/emacs/override-redirect/lisp/vc/vc.el...
View mode: type C-h for help, h for commands, q to quit.

Load-path shadows:
/home/politza/.emacs.d/plugins/pc hides /home/politza/.emacs.d/elpa/pc-1.0/pc
/home/politza/.emacs.d/plugins/switch-focus hides /home/politza/.emacs.d/elpa/pc-1.0/switch-focus
/home/politza/.emacs.d/elpa/yasnippet-20130907.1855/yasnippet hides /home/politza/.emacs.d/plugins/yasnippet-0.6.1c/yasnippet
/home/politza/.emacs.d/plugins/tblc hides /home/politza/.emacs.d/plugins/tblc/tblc
/home/politza/.emacs.d/plugins/haskell-mode/haskell-cabal hides /home/politza/.emacs.d/plugins/haskell/haskell-cabal
/home/politza/.emacs.d/plugins/haskell-mode/haskell-decl-scan hides /home/politza/.emacs.d/plugins/haskell/haskell-decl-scan
/home/politza/.emacs.d/plugins/haskell-mode/haskell-doc hides /home/politza/.emacs.d/plugins/haskell/haskell-doc
/home/politza/.emacs.d/plugins/haskell-mode/ghc-core hides /home/politza/.emacs.d/plugins/haskell/ghc-core
/home/politza/.emacs.d/plugins/haskell-mode/haskell-mode hides /home/politza/.emacs.d/plugins/haskell/haskell-mode
/home/politza/.emacs.d/plugins/haskell-mode/haskell-c hides /home/politza/.emacs.d/plugins/haskell/haskell-c
/home/politza/.emacs.d/plugins/haskell-mode/haskell-indentation hides /home/politza/.emacs.d/plugins/haskell/haskell-indentation
/home/politza/.emacs.d/plugins/haskell-mode/haskell-site-file hides /home/politza/.emacs.d/plugins/haskell/haskell-site-file
/home/politza/.emacs.d/plugins/haskell-mode/haskell-ghci hides /home/politza/.emacs.d/plugins/haskell/haskell-ghci
/home/politza/.emacs.d/plugins/haskell-mode/inf-haskell hides /home/politza/.emacs.d/plugins/haskell/inf-haskell
/home/politza/.emacs.d/plugins/haskell-mode/haskell-indent hides /home/politza/.emacs.d/plugins/haskell/haskell-indent
/home/politza/.emacs.d/plugins/haskell-mode/haskell-hugs hides /home/politza/.emacs.d/plugins/haskell/haskell-hugs
/home/politza/.emacs.d/plugins/haskell-mode/haskell-font-lock hides /home/politza/.emacs.d/plugins/haskell/haskell-font-lock
/home/politza/.emacs.d/plugins/haskell-mode/haskell-simple-indent hides /home/politza/.emacs.d/plugins/haskell/haskell-simple-indent
/home/politza/.emacs.d/plugins/jedi/scratch hides /home/politza/.emacs.d/plugins/ewm/scratch
/home/politza/.emacs.d/elpa/company-20130923.513/.dir-locals hides /home/politza/.emacs.d/plugins/el-get/.dir-locals
/home/politza/.emacs.d/elpa/popup-20130708.2245/popup hides /home/politza/.emacs.d/plugins/auto-complete/popup
/home/politza/.emacs.d/elpa/auto-complete-20130724.1750/auto-complete-config hides /home/politza/.emacs.d/plugins/auto-complete/auto-complete-config
/home/politza/.emacs.d/elpa/auto-complete-20130724.1750/auto-complete hides /home/politza/.emacs.d/plugins/auto-complete/auto-complete
/home/politza/.emacs.d/plugins/pc hides /home/politza/src/emacs/override-redirect/lisp/pc
/home/politza/.emacs.d/elpa/popup-20130708.2245/popup hides /home/politza/src/emacs/override-redirect/lisp/popup
/home/politza/.emacs.d/plugins/jedi/scratch hides /home/politza/src/emacs/override-redirect/lisp/scratch
/home/politza/.emacs.d/plugins/saveplace hides /home/politza/src/emacs/override-redirect/lisp/saveplace
/home/politza/.emacs.d/plugins/imenu hides /home/politza/src/emacs/override-redirect/lisp/imenu
/home/politza/.emacs.d/plugins/term hides /home/politza/src/emacs/override-redirect/lisp/term
/home/politza/.emacs.d/elpa/company-20130923.513/.dir-locals hides /home/politza/src/emacs/override-redirect/lisp/gnus/.dir-locals
/home/politza/.emacs.d/plugins/matlab/matlab hides /usr/share/emacs-snapshot/site-lisp/emacs-goodies-el/matlab
/home/politza/.emacs.d/plugins/boxquote hides /usr/share/emacs-snapshot/site-lisp/emacs-goodies-el/boxquote
/home/politza/.emacs.d/plugins/bm hides /usr/share/emacs-snapshot/site-lisp/emacs-goodies-el/bm
/home/politza/.emacs.d/plugins/haskell-mode/haskell-decl-scan hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-decl-scan
/home/politza/.emacs.d/plugins/haskell-mode/haskell-c hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-c
/home/politza/.emacs.d/plugins/haskell-mode/haskell-ghci hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-ghci
/home/politza/.emacs.d/plugins/haskell-mode/haskell-doc hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-doc
/home/politza/.emacs.d/plugins/haskell-mode/haskell-indent hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-indent
/home/politza/.emacs.d/plugins/haskell-mode/haskell-mode hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-mode
/home/politza/.emacs.d/plugins/haskell-mode/haskell-hugs hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-hugs
/home/politza/.emacs.d/plugins/haskell-mode/haskell-site-file hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-site-file
/home/politza/.emacs.d/plugins/haskell-mode/haskell-cabal hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-cabal
/home/politza/.emacs.d/plugins/haskell-mode/inf-haskell hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/inf-haskell
/home/politza/.emacs.d/plugins/haskell-mode/haskell-font-lock hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-font-lock
/home/politza/.emacs.d/plugins/haskell-mode/haskell-simple-indent hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-simple-indent
/home/politza/.emacs.d/plugins/haskell-mode/haskell-indentation hides /usr/share/emacs-snapshot/site-lisp/haskell-mode/haskell-indentation

Features:
(shadow sort gnus-cite bbdb-message mail-extr nnir nndraft nnmh
bbdb-gnus gnus-agent gnus-srvr gnus-score score-mode nnvirtual nntp
gnus-cache gnus-msg gnus-art mm-uu mml2015 epg-config mm-view mml-smime
smime dig mailcap emacsbug sendmail pp whitespace diff-mode ispell
misearch multi-isearch mule-util holidays hol-loaddefs reftex-dcr
reftex-auc tex-buf font-latex vc-dir ewoc vc vc-dispatcher vc-svn
diary-lib diary-loaddefs semantic/decorate/include semantic/tag-file
cc-langs vc-bzr vc-git cl-font-lock dired-eshell semantic/db-file
data-debug cedet-files doc-view-fixed-scroll emacs-customizations
hypermedia-customizations eww-customizations nogroup-customizations
wp-customizations view-customizations tex-customizations
reftex-customizations reftex-miscellaneous-configurations-customizations
reftex-label-support-customizations
reftex-referencing-labels-customizations
reftex-defining-label-environments-customizations AUCTeX-customizations
preview-customizations preview-latex-customizations
preview-appearance-customizations TeX-parse-customizations
TeX-file-customizations TeX-command-customizations
TeX-view-customizations LaTeX-customizations LaTeX-macro-customizations
LaTeX-math-customizations LaTeX-indentation-customizations
table-customizations table-hooks-customizations outlines-customizations
programming-customizations tools-customizations vc-customizations
log-edit-customizations semantic-customizations pulse-customizations
semantic-imenu-customizations semantic/db-mode semantic/decorate/mode
semantic/decorate pulse makefile-customizations etags-customizations
ediff-customizations diff-customizations diff-mode-customizations
languages-customizations elpy-customizations matlab-customizations
sh-customizations python-customizations rx haskell-customizations
c-customizations semantic/bovine/c hideif cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
semantic/db-find semantic/db-ref semantic/bovine/c-by semantic/lex-spp
semantic/idle semantic/bovine/gcc semantic/dep semantic/bovine
semantic/analyze semantic/sort semantic/scope semantic/analyze/fcn
semantic/db eieio-base semantic/ctxt semantic/format ezimage
semantic/tag-ls semantic/find asm-customizations
multimedia-customizations image-customizations help-customizations
ekey-customizations info-lookup-customizations info-customizations
customize-customizations custom-buffer-customizations
apropos-customizations help-mode files-customizations
uniquify-customizations uniquify sunrise-customizations
recentf-customizations find-file-customizations backup-customizations
faces-customizations highlight-symbol-customizations
font-lock-customizations hi-lock-customizations facemenu-customizations
external-customizations server-customizations processes-customizations
shell-customizations proced-customizations gud-customizations
tooltip-customizations grep-customizations compilation-customizations
next-error-customizations comint-customizations SQL-customizations
man-customizations environment-customizations xterm-customizations
windows-customizations winner-customizations minibuffer-customizations
savehist-customizations completion-spelling lib-string
menu-customizations keyboard-customizations chistory-customizations
initialization-customizations frames-customizations
ediff-window-customizations desktop-customizations desktop frameset
dired-customizations dired-x-customizations dired-x
dired-details-customizations editing-customizations
paragraphs-customizations matching-customizations
paren-matching-customizations paren-showing-customizations
isearch-customizations bookmark-customizations killing-customizations
indent-customizations fill-customizations emulations-customizations
editing-basics-customizations development-customizations
lisp-customizations re-builder-customizations
inferior-lisp-customizations ielm-customizations ert-customizations
edebug-customizations bytecomp-customizations advice-customizations
internal-customizations alloc-customizations extensions-customizations
eldoc-customizations cust-print-customizations data-customizations
save-place-customizations convenience-customizations mimo-customizations
mimo diminish-customizations diminish iedit-customizations
imenu-tree-customizations tags-tree-customizations
company-customizations workgroups-customizations
window-numbering-customizations pabbrev-customizations
kmacro-customizations imenu-customizations ibuffer-customizations
ibuf-macs hl-line-customizations hippie-expand-customizations
file-cache-customizations ffap-customizations completion-customizations
pc-completion-customizations jedi-customizations iswitchb-customizations
auto-complete-customizations pc pcase switch-focus color hl-line
browse-kill-ring-customizations auto-revert-customizations
auto-insert-customizations Buffer-menu-customizations
comm-customizations tramp-customizations browse-url-customizations
applications-customizations mediawiki-customizations w3m-customizations
package-customizations mail-customizations bbdb-customizations
bbdb-sendmail-customizations bbdb-mua-customizations bbdb-mua bbdb-com
crm bbdb smtpmail-customizations shr-customizations
sendmail-customizations gnus-customizations nnmail-customizations
nnmail-split-customizations mail-source-customizations
gnus-summary-customizations gnus-thread-customizations
gnus-summary-various-customizations gnus-summary-sort-customizations
gnus-summary-marks-customizations
gnus-summary-maneuvering-customizations
gnus-summary-format-customizations parse-time-rfc2822
gnus-summary-exit-customizations gnus-sum gnus-group gnus-undo
gnus-start gnus-spec gnus-win gnus-start-customizations
gnus-server-customizations gnus-message-customizations
message-customizations message-various-customizations
message-sending-customizations message-buffers-customizations
gnus-group-customizations gnus-group-visual-customizations
gnus-nnimap-format nnimap nnmail gnus-int mail-source message rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mailabbrev gmm-utils mailheader parse-time tls utf7 netrc
nnoo gnus gnus-ems nnheader mail-utils gnus-group-various-customizations
gnus-group-select-customizations gnus-files-customizations
gnus-newsrc-customizations gnus-exit-customizations
gnus-article-customizations gnus-article-hiding-customizations
ispell-customizations eshell-customizations eshell-module-customizations
eshell-smart-customizations eshell-hist-customizations
eshell-mode-customizations edebug doc-view-customizations
pdf-tools-customizations pdf-sync-customizations
pdf-annot-customizations pdf-isearch-customizations pdf-sync pdf-annot
pdf-occur tablist tablist-filter semantic/wisent/comp semantic/wisent
semantic/wisent/wisent semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw mode-local cedet pdf-history
pdf-outline pdf-links pdf-isearch pdf-misc imenu pdf-info tq pdf-render
pdf-tools pdf-util gnus-range warnings doc-view jka-compr image-mode
calendar-customizations org-customizations org-structure-customizations
org-plain-lists-customizations org-edit-structure-customizations
org-startup-customizations org-link-customizations
org-latex-customizations org-appearance-customizations
holidays-customizations diary-customizations calculator-customizations
calc-customizations server recentf tree-widget .autoload paren
window-numbering w3m browse-url timezone w3m-hist w3m-e23 w3m-ccl ccl
w3m-fsf w3m-favicon w3m-image w3m-proc w3m-util view tramp tramp-compat
tramp-loaddefs trampver shell track-last-window scroll-other-window
saveplace savehist reftex reftex-vars pabbrev org ob-tangle ob-ref
ob-lob ob-table org-footnote org-src ob-comint ob-keys org-pcomplete
org-list org-faces org-entities noutline outline org-version
ob-emacs-lisp ob org-compat org-macs ob-eval org-loaddefs format-spec
find-func cal-menu calendar cal-loaddefs lib-edit lib-window lib-isearch
lib-buffer reveal iswitchb lib-basic lib-lispext latex easy-mmode
tex-style tex dbus xml tex-site auto-loads info-look info ibuffer
hippie-exp grep compile filecache edit-minibuffer eldoc-eval pcomplete
esh-var esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg esh-groups
eshell esh-module esh-mode esh-util ekey assoc dired-details+ dired
dired-details cool-prefix-bindings winner lib-kbd comint-history comint
ansi-color ring browse-kill-ring advice anticus edmacro kmacro derived
cl-macs gv ffap thingatpt url-parse auth-source eieio byte-opt bytecomp
byte-compile cconv eieio-core gnus-util mm-util mail-prsvr
password-cache url-vars eldoc help-fns cus-edit easymenu cus-start
cus-load wid-edit cl cl-loaddefs cl-lib bbdb-loaddefs
cl-format-autoloads package time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)