Permalink
Browse files

Allow multiple types.

  • Loading branch information...
1 parent 9fefde4 commit 64f63c215afc56db4205840345b66760f41c58dc @nschum committed Apr 5, 2009
Showing with 67 additions and 65 deletions.
  1. +67 −65 full-ack.el
View
132 full-ack.el
@@ -56,12 +56,11 @@
(defcustom ack-mode-type-alist nil
"*Matches major modes to searched file types.
This overrides values in `ack-mode-default-type-alist'. The car in each
-list element is a major mode, the cdr is a string, which represents
+list element is a major mode, the rest are strings representing values of
the --type argument used by `ack-same'."
:group 'full-ack
:type '(repeat (cons (symbol :tag "Major mode")
- (choice (string :tag "ack type")
- (const :tag "Search all" nil)))))
+ (repeat (string :tag "ack type")))))
(defcustom ack-mode-extension-alist nil
"*Matches major modes to searched file extensions.
@@ -169,57 +168,56 @@ used without confirmation."
(defconst ack-mode-default-type-alist
;; Some of these names are guessed. More should be constantly added.
- '((actionscript-mode . "actionscript")
- (LaTeX-mode . "tex")
- (TeX-mode . "tex")
- (asm-mode . "asm")
- (batch-file-mode . "batch")
- (c++-mode . "cpp")
- (c-mode . "cc")
- (cfmx-mode . "cfmx")
- (cperl-mode . "perl")
- (csharp-mode . "csharp")
- (css-mode . "css")
- (emacs-lisp-mode . "elisp")
- (erlang-mode . "erlang")
- (espresso-mode . "js")
- (fortran-mode . "fortran")
- (haskell-mode . "haskell")
- (hexl-mode . "binary")
- (html-mode . "html")
- (java-mode . "java")
- (javascript-mode . "js")
- (jde-mode . "java")
- (js2-mode . "js")
- (jsp-mode . "jsp")
- (latex-mode . "tex")
- (lisp-mode . "lisp")
- (lua-mode . "lua")
- (makefile-mode . "make")
- (mason-mode . "mason")
- (nxml-mode . "xml")
- (objc-mode . "objc")
- ;; (objc++-mode . "objcpp")
- (ocaml-mode . "ocaml")
- (parrot-mode . "parrot")
- (perl-mode . "perl")
- (php-mode . "php")
- (plone-mode . "plone")
- (python-mode . "python")
- (ruby-mode . "ruby")
- (scheme-mode . "scheme")
- (shell-script-mode . "shell")
- (skipped-mode . "skipped")
- (smalltalk-mode . "smalltalk")
- (sql-mode . "sql")
- (tcl-mode . "tcl")
- (tex-mode . "tex")
- (text-mode . "text")
- (tt-mode . "tt")
- (vb-mode . "vb")
- (vim-mode . "vim")
- (xml-mode . "xml")
- (yaml-mode . "yaml"))
+ '((actionscript-mode "actionscript")
+ (LaTeX-mode "tex")
+ (TeX-mode "tex")
+ (asm-mode "asm")
+ (batch-file-mode "batch")
+ (c++-mode "cpp")
+ (c-mode "cc")
+ (cfmx-mode "cfmx")
+ (cperl-mode "perl")
+ (csharp-mode "csharp")
+ (css-mode "css")
+ (emacs-lisp-mode "elisp")
+ (erlang-mode "erlang")
+ (espresso-mode "js")
+ (fortran-mode "fortran")
+ (haskell-mode "haskell")
+ (hexl-mode "binary")
+ (html-mode "html")
+ (java-mode "java")
+ (javascript-mode "js")
+ (jde-mode "java")
+ (js2-mode "js")
+ (jsp-mode "jsp")
+ (latex-mode "tex")
+ (lisp-mode "lisp")
+ (lua-mode "lua")
+ (makefile-mode "make")
+ (mason-mode "mason")
+ (nxml-mode "xml")
+ (objc-mode "objc" "objcpp")
+ (ocaml-mode "ocaml")
+ (parrot-mode "parrot")
+ (perl-mode "perl")
+ (php-mode "php")
+ (plone-mode "plone")
+ (python-mode "python")
+ (ruby-mode "ruby")
+ (scheme-mode "scheme")
+ (shell-script-mode "shell")
+ (skipped-mode "skipped")
+ (smalltalk-mode "smalltalk")
+ (sql-mode "sql")
+ (tcl-mode "tcl")
+ (tex-mode "tex")
+ (text-mode "text")
+ (tt-mode "tt")
+ (vb-mode "vb")
+ (vim-mode "vim")
+ (xml-mode "xml")
+ (yaml-mode "yaml"))
"Default values for `ack-mode-type-alist', which see.")
(defconst ack-mode-default-extension-alist
@@ -228,19 +226,23 @@ used without confirmation."
(defun ack-type-for-major-mode (mode)
"Return the --type and --type-set arguments for major mode MODE."
- (let ((type (cdr (or (assoc mode ack-mode-type-alist)
- (assoc mode ack-mode-default-type-alist))))
+ (let ((types (cdr (or (assoc mode ack-mode-type-alist)
+ (assoc mode ack-mode-default-type-alist))))
(ext (cdr (or (assoc mode ack-mode-extension-alist)
- (assoc mode ack-mode-default-extension-alist)))))
+ (assoc mode ack-mode-default-extension-alist))))
+ result)
+ (dolist (type types)
+ (push type result)
+ (push "--type" result))
(if ext
- (if type
- (list "--type-add" (concat type "=" (mapconcat 'identity ext ","))
- "--type" type)
- (setq type "full-ack-custom-type")
- (list "--type-set" (concat type "=" (mapconcat 'identity ext ","))
- "--type" type))
- (when type
- (list "--type" type)))))
+ (if types
+ `("--type-add" ,(concat (car types)
+ "=" (mapconcat 'identity ext ","))
+ . ,result)
+ (list "--type-set" (concat "full-ack-custom-type="
+ (mapconcat 'identity ext ","))
+ "--type" "full-ack-custom-type"))
+ result)))
;;; root ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

0 comments on commit 64f63c2

Please sign in to comment.