Skip to content

Commit

Permalink
new feature: files listed in .cvsignore can be excluded from sources-…
Browse files Browse the repository at this point in the history
…display.
  • Loading branch information
berndl committed Mar 21, 2003
1 parent 8561fe3 commit 748fadd
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 19 deletions.
14 changes: 9 additions & 5 deletions NEWS
Expand Up @@ -29,20 +29,24 @@

*** `ecb-toggle-compile-window' now has a key-binding: [C-c . \]

** New option `ecb-sources-exclude-cvsignore' which allows to exclude files from
being displayed in the sources-buffer if they are contained in a .cvsignore
file.

** Now also layouts with user-defined special ecb-windows can be created
interactively. See the online-manual for further details.

** Now user-extensions can be added to the popup-menues of the tree-buffers.
See new options `ecb-directories-menu-user-extension',
`ecb-sources-menu-user-extension', `ecb-methods-menu-user-extension',
`ecb-history-menu-user-extension'.

** ECB now also works with buffers "online" extracted from archives.
Buffers extracted from an archive in `tar-mode' or `archive-mode' are now
correct handled as if they were normal file-buffers. This feature doesn't
work with XEmacs cause of its tar-mode and arc-mode implementation which
does not handle extracted files as normal files.

** Now user-extensions can be added to the popup-menues of the tree-buffers.
See new options `ecb-directories-menu-user-extension',
`ecb-sources-menu-user-extension', `ecb-methods-menu-user-extension',
`ecb-history-menu-user-extension'.

** ECB now checks at load-time if the required packages semantic and eieio are
at least available - regardless of the needed version. If at least one of
these packages is missing then ECB offers to download and install it. More
Expand Down
7 changes: 0 additions & 7 deletions TODO
Expand Up @@ -19,10 +19,3 @@
either filenames (in case of real files) or buffer-object in case of buffers
which can be parsed but are not real files (not saved sources or
archive-extracts for example).

- (BUG) if we are in a compilation buffer, and we do a
switch-to-buffer-other-window, and the buffer currently in the edit window is
already the buffer we want to switch to, we should NOT split the window again
because this would yeild two windows each with the same buffer.

- Ignore source files specified in .cvsignore files. (JN)
12 changes: 12 additions & 0 deletions ecb-util.el
Expand Up @@ -714,6 +714,18 @@ Since it actually calls `start-process', not all features will work."
;; (if (not (sit-for timeout)) (read-event))
))))

(defun ecb-file-content-as-string (file)
"If FILE exists and is readable returns the contents as a string otherwise
return nil.
Note: No major/minor-mode is activated and no local variables are evaluated
for FILE, but proper EOL-conversion and charcater interpretation is done!"
(let ((exp-filename (expand-file-name file)))
(if (and (file-exists-p exp-filename)
(file-readable-p exp-filename))
(with-temp-buffer
(insert-file-contents exp-filename)
(buffer-string)))))


(silentcomp-provide 'ecb-util)

Expand Down
62 changes: 57 additions & 5 deletions ecb.el
Expand Up @@ -699,6 +699,24 @@ then activating ECB again!"
:group 'ecb-sources
:type 'string)


(defcustom ecb-sources-exclude-cvsignore nil
"*Specify if files contained in a .cvsignore should be excluded.
Value is a list of regular expressions or nil. If you want to exclude files
listed in a .cvsignore-file from being displayed in the ecb-sources-buffer
then specify a regexp for such a directory.
If you want to exclude the contents of .cvsignore-files for every directory
then you should add one regexp \".*\" which matches every directory.
If you never want to exclude the contents of .cvsignore-files then set this
option to nil. This is the default."
:group 'ecb-sources
:group 'ecb-directories
:type '(repeat (regexp :tag "Directory-regexp")))


(defcustom ecb-source-file-regexps
'((".*" . ("\\(^\\(\\.\\|#\\)\\|\\(~$\\|\\.\\(elc\\|obj\\|o\\|class\\|lib\\|dll\\|a\\|so\\|cache\\)$\\)\\)"
"^\\.\\(emacs\\|gnus\\)$")))
Expand All @@ -716,9 +734,15 @@ contain an always matching directory-regexp \(\".*\")!
So the value of this option is a list of cons-cells where the car is a
directory regexp and the cdr is a 2 element list where the first element is a
exclude regexp and the second element is a include regexp. A file is displayed
in the source-buffer of ECB iff: The file does not match the exclude regexp OR
the file matches the include regexp. There are three predefined and useful
combinations of an exclude and include regexp:
in the sources-buffer of ECB iff: The file does not match the exclude regexp
OR the file matches the include regexp.
But regardless of the value of this option a file F is never displayed in the
sources-buffer if the directory matches `ecb-sources-exclude-cvsignore'
and the directory contains a file .cvsignore which contains F as an entry!
There are three predefined and useful combinations of an exclude and include
regexp:
- All files
- All, but no backup, object, lib or ini-files \(except .emacs and .gnus). This
means all files except those starting with \".\", \"#\" or ending with
Expand Down Expand Up @@ -2604,6 +2628,30 @@ and NUMBER-OF-CONTENTS is greater then the related threshold."
(throw 'exit (cdr elem))))
nil))))


(defun ecb-files-from-cvsignore (dir)
"Return an expanded list of filenames which are excluded by the .cvsignore
file in current directory."
(let ((cvsignore-content (ecb-file-content-as-string
(expand-file-name ".cvsignore" dir)))
(files nil))
(when cvsignore-content
(dolist (f (split-string cvsignore-content))
(setq files (append (directory-files dir nil (wildcard-to-regexp f))
files)))
files)))

(defun ecb-check-directory-for-cvsignore-exclude (dir)
"Return not nil if DIR matches a regexp in `ecb-sources-exclude-cvsignore'."
(catch 'exit
(dolist (elem ecb-sources-exclude-cvsignore)
(let ((case-fold-search t))
(save-match-data
(if (string-match elem dir)
(throw 'exit elem)))
nil))))


(defun ecb-get-files-and-subdirs (dir)
"Return a cons cell where car is a list of all files to display in DIR and
cdr is a list of all subdirs to display in DIR. Both lists are sorted
Expand All @@ -2614,6 +2662,8 @@ according to `ecb-sources-sort-method'."
(source-regexps (or (ecb-check-directory-for-source-regexps
(ecb-fix-filename dir))
'("" "")))
(cvsignore-files (if (ecb-check-directory-for-cvsignore-exclude dir)
(ecb-files-from-cvsignore dir)))
sorted-files source-files subdirs cache-elem)
;; if necessary sort FILES
(setq sorted-files
Expand All @@ -2635,9 +2685,11 @@ according to `ecb-sources-sort-method'."
(if (file-directory-p (ecb-fix-filename dir file))
(if (not (string-match ecb-excluded-directories-regexp file))
(setq subdirs (append subdirs (list file))))
(if (or (string-match (cadr source-regexps) file)
(not (string-match (car source-regexps) file)))
(if (and (not (member file cvsignore-files))
(or (string-match (cadr source-regexps) file)
(not (string-match (car source-regexps) file))))
(setq source-files (append source-files (list file))))))

(setq cache-elem (cons dir (cons source-files subdirs)))
;; check if this directory must be cached
(if (ecb-check-directory-for-caching dir (length sorted-files))
Expand Down
29 changes: 27 additions & 2 deletions ecb.texi
Expand Up @@ -3782,8 +3782,15 @@ directory regexp and the cdr is a 2 element list where the first
element is a exclude regexp and the second element is a include
regexp. A file is displayed in the source-buffer of ECB iff: The file
does not match the exclude regexp OR the file matches the include
regexp. There are three predefined and useful combinations of an
exclude and include regexp:
regexp.

But regardless of the value of this option a file F is never displayed
in the sources-buffer if the directory matches
@code{ecb-sources-exclude-cvsignore} and the directory contains a file
.cvsignore which contains F as an entry!

There are three predefined and useful combinations of an exclude and
include regexp:

@itemize @bullet
@item All files
Expand Down Expand Up @@ -3825,6 +3832,24 @@ Changes for this option at runtime will take affect only after
deactivating and then activating ECB again!
@end defopt


@defopt sources-exclude-cvsignore
Specify if files contained in a @file{.cvsignore} should be
excluded.

Value is a list of regular expressions or nil. If you want to exclude
files listed in a @file{.cvsignore}-file from being displayed in the
ecb-sources-buffer then specify a regexp for such a directory.

If you want to exclude the contents of @file{.cvsignore}-files for
every directory then you should add one regexp ``.*'' which matches
every directory.

If you never want to exclude the contents of @file{.cvsignore}-files
then set this option to nil.
@end defopt


@defopt sources-menu-sorter
Function which re-sorts the menu-entries of the directories buffer.

Expand Down

0 comments on commit 748fadd

Please sign in to comment.