gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ;;; anything.el --- open anything


From: Tassilo Horn
Subject: Re: ;;; anything.el --- open anything
Date: Tue, 17 Jul 2007 09:40:09 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux)

"address@hidden" <address@hidden> writes:

Hi Tamas,

>>   - Use a custom face for the headlines in the *anything* buffer. I saw
>>     that was mentioned earlier and I'm ok with the "first functionality,
>>     then eye-candy" approach.
>
> Eye candy gets implemented faster if patches are submitted. ;)

Ok, here's a patch that makes anything-header-face a face you can
customize with `customize-face'. By default it's bold and underlined.

In addition to that I reversed the args of `anything-source-locate' so
that the pattern follows directly the "-r" to make it work with GNU
slocate 3.1.

I added a new asynchronous source for the tracker desktop search, too,
see `anything-source-tracker-search'. That's quite identical to the
locate source, but it doesn't refresh after the pattern changes. It
won't be displayed at all after the pattern changes after the first
search. Do you know what the problem could be?

I tried the start-process line in *scratch* and it worked as expected...

Bye,
Tassilo
--8<---------------cut here---------------start------------->8---
diff -u /home/heimdall/elisp/anything.el.orig /home/heimdall/elisp/anything.el
--- /home/heimdall/elisp/anything.el.orig       2007-07-17 09:24:46.000000000 
+0200
+++ /home/heimdall/elisp/anything.el    2007-07-17 09:29:05.000000000 +0200
@@ -51,7 +51,7 @@
 
 (require 'cl)
 
-;; User Configuration 
+;; User Configuration
 
 ;; This is only an example. Customize it to your own taste!
 (defvar anything-sources `(((name . "Buffers")
@@ -234,7 +234,7 @@
   "It's a list of (TYPE . FUNCTION) pairs. The function is called
   with two arguments when the action list from the source is
   assembled. The first argument is the list of actions, the
-  second is the current selection. 
+  second is the current selection.
 
   The function should return a transformed action list.
 
@@ -265,7 +265,8 @@
   "Keymap for anything.")
 
 
-(defvar anything-header-face 'header-line
+(defface anything-header-face
+  '((t (:bold t :underline t)))
   "Face for header lines in the anything buffer.")
 
 ;;----------------------------------------------------------------------
@@ -275,28 +276,40 @@
 ;;----------------------------------------------------------------------
 
 (defvar anything-source-emacs-commands
-  `((name . "Emacs Commands") 
-    (candidates . ,(let (commands) 
-                     (mapatoms (lambda (a) 
-                                 (if (commandp a) 
-                                     (push (symbol-name a) 
-                                           commands)))) 
-                     (sort commands 'string-lessp))) 
-    (action . (lambda (command-name) 
+  `((name . "Emacs Commands")
+    (candidates . ,(let (commands)
+                     (mapatoms (lambda (a)
+                                 (if (commandp a)
+                                     (push (symbol-name a)
+                                           commands))))
+                     (sort commands 'string-lessp)))
+    (action . (lambda (command-name)
                 (call-interactively (intern command-name)))))
   "Source for completing and invoking Emacs commands.")
 
 
-(defvar anything-source-locate 
-  '((name . "Locate")        
+(defvar anything-source-locate
+  '((name . "Locate")
     (candidates . (lambda ()
                     (start-process "locate-process" nil
-                                   "locate" "-r" "-i"
+                                   "locate" "-i" "-r"
                                    anything-pattern)))
     (type . file)
     (requires-pattern . 3))
   "Source for retrieving files matching the current input pattern
-  with locate.")
+with locate.")
+
+
+(defvar anything-source-tracker-search
+  '((name . "Tracker Search")
+    (candidates . (lambda ()
+                    (start-process "tracker-search-process" nil
+                                   "tracker-search"
+                                   anything-pattern)))
+    (type . file)
+    (requires-pattern . 3))
+  "Source for retrieving files matching the current input pattern
+with the tracker desktop search.")
 
 
 ;;----------------------------------------------------------------------
@@ -345,7 +358,7 @@
                (or (equal name anything-buffer)
                    (eq ?\  (aref name 0))))
              (mapcar 'buffer-name (buffer-list))))
-  
+
 
 (defun anything-check-minibuffer-input ()
   "Extract input string from the minibuffer and check if it needs
@@ -405,7 +418,7 @@
         (progn
           (setq matches (anything-get-cached-candidates source))
           (if (> (length matches) anything-candidate-number-limit)
-              (setq matches 
+              (setq matches
                     (subseq matches 0 anything-candidate-number-limit))))
 
       (let ((item-count 0))
@@ -445,7 +458,7 @@
       (funcall insert-function match)
 
     (funcall insert-function (car match))
-    (put-text-property (line-beginning-position) (line-end-position) 
+    (put-text-property (line-beginning-position) (line-end-position)
                        'anything-realvalue (cdr match)))
   (funcall insert-function "\n"))
 
@@ -454,7 +467,7 @@
   "Process delayed sources if the user is idle for
 `anything-idle-delay' seconds."
   (if (sit-for anything-idle-delay)
-      (with-current-buffer anything-buffer        
+      (with-current-buffer anything-buffer
         (save-excursion
           (goto-char (point-max))
           (dolist (source delayed-sources)
@@ -513,7 +526,7 @@
 
 (defun anything-list-but-not-lambda-p (x)
   "Return t if x is a list, but not a lambda function."
-  (and (listp x)       
+  (and (listp x)
        (not (functionp x))))
 
 
@@ -607,7 +620,7 @@
       (move-overlay anything-selection-overlay (point-min) (point-min)
                     (get-buffer anything-buffer))
 
-    (setq anything-selection-overlay 
+    (setq anything-selection-overlay
           (make-overlay (point-min) (point-min) (get-buffer anything-buffer)))
     (overlay-put anything-selection-overlay 'face 'highlight))
 
@@ -737,7 +750,7 @@
              (overlay (nth index anything-digit-overlays)))
         (if (overlay-buffer overlay)
             (save-selected-window
-              (select-window (get-buffer-window anything-buffer))          
+              (select-window (get-buffer-window anything-buffer))
               (goto-char (overlay-start overlay))
               (anything-mark-current-line)
               (anything-exit-minibuffer))))))
@@ -784,7 +797,7 @@
     (if (processp candidates)
         candidates
       (anything-transform-candidates candidates source))))
-         
+
 
 (defun anything-transform-candidates (candidates source)
   "Transform CANDIDATES according to `anything-candidate-transformers'."
@@ -810,7 +823,7 @@
       (if (processp candidates)
           (progn
             (push (cons candidates
-                        (append source 
+                        (append source
                                 (list (cons 'item-count 0)
                                       (cons 'incomplete-line ""))))
                   anything-async-processes)
@@ -835,7 +848,7 @@
       (save-excursion
         (if insertion-marker
             (goto-char insertion-marker)
-        
+
           (goto-char (point-max))
           (anything-insert-header (cdr (assoc 'name process-info)))
           (setcdr process-assoc
@@ -855,7 +868,7 @@
               (when (>= (cdr item-count-info) anything-candidate-number-limit)
                 (setq lines nil)
                 (anything-kill-async-process process)))
-                  
+
             (pop lines))
 
           (setq candidates (reverse candidates))
@@ -885,11 +898,11 @@
   "Kill PROCESS and detach the associated functions."
   (set-process-filter process nil)
   (delete-process process))
-  
+
 
 (defun anything-transform-files (files)
   "Transform file candidates."
-  (let ((boring-file-regexp 
+  (let ((boring-file-regexp
          (concat "\\(?:" (regexp-opt completion-ignored-extensions) "\\)\\'")))
     (mapcar (lambda (file)
               ;; Add shadow face property to boring files.
@@ -918,7 +931,7 @@
     (put-text-property (line-beginning-position)
                        (line-end-position) 'anything-header t)
     (insert "\n")
-    (put-text-property start (point) 'face anything-header-face)))
+    (put-text-property start (point) 'face 'anything-header-face)))
 
 
 ;;----------------------------------------------------------------------
@@ -994,7 +1007,7 @@
     (add-hook 'anything-update-hook 'anything-iswitchb-handle-update)
 
     (anything-initialize)
-    
+
     (add-hook 'post-command-hook 'anything-iswitchb-check-input)))
 
 
@@ -1034,15 +1047,15 @@
     (with-current-buffer (window-buffer (active-minibuffer-window))
       (let* ((anything-prefix "anything-")
              (prefix-length (length anything-prefix))
-             (commands 
+             (commands
               (delete-dups
                (remove-if 'null
-                          (mapcar 
+                          (mapcar
                            (lambda (binding)
                              (let ((command (cdr binding)))
                                (when (and (symbolp command)
-                                          (eq (compare-strings 
-                                               anything-prefix 
+                                          (eq (compare-strings
+                                               anything-prefix
                                                0 prefix-length
                                                (symbol-name command)
                                                0 prefix-length)
@@ -1050,7 +1063,7 @@
                                  command)))
                            (cdr anything-map)))))
              (bindings (mapcar (lambda (command)
-                                 (cons command 
+                                 (cons command
                                        (where-is-internal command 
anything-map)))
                                commands)))
 
@@ -1066,7 +1079,7 @@
             (let ((old-command (lookup-key (current-local-map) key)))
               (unless (and anything-iswitchb-dont-touch-iswithcb-keys
                            (symbolp old-command)
-                           (eq (compare-strings iswitchb-prefix 
+                           (eq (compare-strings iswitchb-prefix
                                                 0 prefix-length
                                                 (symbol-name old-command)
                                                 0 prefix-length)

Diff finished.  Tue Jul 17 09:30:10 2007
--8<---------------cut here---------------end--------------->8----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]