Re: ;;; anything.el --- open anything
Here's a demontstration for the option (anything-filtered-candidate- transformers) added today. I didn't want to stuff into anything.el, so I post it here. Maybe it should go to anything-config.el. It's a candidate sorter which places those candidates first in the list of matches which you selected before. The more frequently you use an item the closer it is to top of the list, so you can select frequent selections more easily. In addition if the current pattern matches one of the previous ones used to select an item then those items are put at the very beginning of the list, so you can have a sort of automatic bookmarks if you use the same pattern to select the same item again and again. So it's an adaptive candidate sorter which learns which candidates you select frequently and makes them more accessible for you. It's only a quick implementation. It surely could be improved. It's not extensively tested, but it seems to work well. To activate add the sorter function to the desired types: (setq anything-filtered-candidate-transformers '((file . anything-adaptive-sort))) and load this code: (defvar anything-adaptive-done nil) (defvar anything-adaptive-history nil) (defvar anything-adaptive-history-file ~/.anything_adaptive_history) (defvar anything-adaptive-history-length 50 Max number of candidates stored for a source.) (defadvice anything-initialize (before anything-adaptive-initialize activate) (setq anything-adaptive-done nil)) (defadvice anything-exit-minibuffer (before anything-adaptive-exit- minibuffer activate) (anything-adaptive-store-selection)) (defadvice anything-select-action (before anything-adaptive-select- action activate) (anything-adaptive-store-selection)) (defun anything-adaptive-store-selection () (unless anything-adaptive-done (setq anything-adaptive-done t) (let* ((source-name (assoc-default 'name (anything-get-current- source))) (source-info (or (assoc source-name anything-adaptive- history) (progn (push (list source-name) anything- adaptive-history) (car anything-adaptive-history (selection (anything-get-selection)) (selection-info (or (let ((found (assoc selection (cdr source-info (when found (setcdr source-info (cons found (delete found (cdr source-info found)) (let ((new (list selection))) (setcdr source-info (cons new (cdr source-info))) new))) (pattern-info (or (let ((found (assoc anything-pattern (cdr selection-info (when found (setcdr selection-info (cons found (delete found (cdr selection-info found)) (let ((new (cons anything-pattern 0))) (setcdr selection-info (cons new (cdr selection- info))) new (setcdr pattern-info (1+ (cdr pattern-info))) (if ( (length (cdr selection-info)) anything-adaptive-history- length) (setcdr selection-info (subseq (cdr selection-info) 0 anything-adaptive- history-length)) (load-file anything-adaptive-history-file) (add-hook 'kill-emacs-hook 'anything-adaptive-save-history) (defun anything-adaptive-save-history () (interactive) (with-temp-buffer (insert ;; -*- mode: emacs-lisp -*-\n ;; History entries used for anything adaptive display.\n) (prin1 `(setq anything-adaptive-history ',anything-adaptive- history) (current-buffer)) (insert ?\n) (write-region (point-min) (point-max) anything-adaptive-history- file nil (unless (interactive-p) 'quiet (defun anything-adaptive-sort (source candidates) (let* ((source-name (assoc-default 'name source)) (source-info (assoc source-name anything-adaptive-history))) (if source-info (let ((usage (mapcar (lambda (candidate-info) (let ((count 0)) (dolist (pattern-info (cdr candidate-info)) (if (not (equal (car pattern-info) anything-pattern)) (incf count (cdr pattern-info)) (setq count (+ 1 (cdr pattern- info))) (return))) (cons (car candidate-info) count))) (cdr source-info))) sorted)
Re: ;;; anything.el --- open anything
Hi Tassilo, Tassilo Horn [EMAIL PROTECTED] writes: [EMAIL PROTECTED] writes: Restoring the eval-after-load statement at the top of the code and eliminating the (require 'anything) at the bottom of the code fixes things. But with the eval-after-load anything.el was loaded before anything-config.el and then the keymaps of anything.el were used. I think I have to read through the docs of eval-after-load a bit mare carefully... (I'll do that as soon as possible.) It looks like you Tamas are caught in a bit of a catch22 here. You need to have your defvar's evaluated before the same ones in anything.el are so you want anything-config.el to be loaded first. However, if anything.el is loaded after anything-config.el, then the defun's that have the same name get redefined by anything.el (for example: anything-transform-files). It looks like you'll have to do 1 of 3 things: 1. If you load anything.el before anything-config.el, you need to change your defvar's to setq's 2. If you load anything.el after anything-config.el, Tamas will need to wrap his defun's with a check to see whether a function is already defined and only do the defun if the function hasn't already been defined. 3. You could have all your defvar's before the (require 'anything) and all you defun's after that statement so that your version of the defvar's and defun's are both used. - Bill ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
Hi Tamas, On Aug 3, 6:21 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Here's a demontstration for the option (anything-filtered-candidate- transformers) added today. I didn't want to stuff into anything.el, so I post it here. Maybe it should go to anything-config.el. It's a candidate sorter which places those candidates first in the list of matches which you selected before. The more frequently you use an item the closer it is to top of the list, so you can select frequent selections more easily. In addition if the current pattern matches one of the previous ones used to select an item then those items are put at the very beginning of the list, so you can have a sort of automatic bookmarks if you use the same pattern to select the same item again and again. So it's an adaptive candidate sorter which learns which candidates you select frequently and makes them more accessible for you. It's only a quick implementation. It surely could be improved. It's not extensively tested, but it seems to work well. Conceptually, this sounds like a great idea (it's also something that Quicksilver does), but it doesn't seem to work for me. I downloaded the latest anything.el, created an empty ~/.anything_adaptive_history file and evaluated your code snippets. I then call up anything and select a file. At this point, I would have thought my selection would be recorded in the history file. However, after my first selection, I don't get anything written into the history file and I subsequently lose the files in Current Directory and File Name History categories when I call up anything again. I haven't spent any time looking at the code, but perhaps I missed out some step? - Bill ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
On Aug 3, 7:10 pm, [EMAIL PROTECTED] wrote: Hi Tamas, On Aug 3, 6:21 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Here's a demontstration for the option (anything-filtered-candidate- transformers) added today. I didn't want to stuff into anything.el, so I post it here. Maybe it should go to anything-config.el. It's a candidate sorter which places those candidates first in the list of matches which you selected before. The more frequently you use an item the closer it is to top of the list, so you can select frequent selections more easily. In addition if the current pattern matches one of the previous ones used to select an item then those items are put at the very beginning of the list, so you can have a sort of automatic bookmarks if you use the same pattern to select the same item again and again. So it's an adaptive candidate sorter which learns which candidates you select frequently and makes them more accessible for you. It's only a quick implementation. It surely could be improved. It's not extensively tested, but it seems to work well. Conceptually, this sounds like a great idea (it's also something that Quicksilver does), but it doesn't seem to work for me. Hi, I tried it and it didn't work for me either. :) I left a bug in it which I now fixed. It should work now. I uploaded it to Emacs Wiki temporarily until Tassilo decides if it's worthy of inclusion into anything-config.el http://www.emacswiki.org/cgi-bin/wiki/anything-adaptive.el /Tamas ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
On Aug 3, 7:38 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Aug 3, 7:10 pm, [EMAIL PROTECTED] wrote: Hi Tamas, On Aug 3, 6:21 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Here's a demontstration for the option (anything-filtered-candidate- transformers) added today. I didn't want to stuff into anything.el, so I post it here. Maybe it should go to anything-config.el. It's a candidate sorter which places those candidates first in the list of matches which you selected before. The more frequently you use an item the closer it is to top of the list, so you can select frequent selections more easily. In addition if the current pattern matches one of the previous ones used to select an item then those items are put at the very beginning of the list, so you can have a sort of automatic bookmarks if you use the same pattern to select the same item again and again. So it's an adaptive candidate sorter which learns which candidates you select frequently and makes them more accessible for you. It's only a quick implementation. It surely could be improved. It's not extensively tested, but it seems to work well. Conceptually, this sounds like a great idea (it's also something that Quicksilver does), but it doesn't seem to work for me. Hi, I tried it and it didn't work for me either. :) I left a bug in it which I now fixed. It should work now. You can check the value of variable anything-adaptive-history to see if it records anything. ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
On Aug 3, 6:47 pm, [EMAIL PROTECTED] wrote: 2. If you load anything.el after anything-config.el, Tamas will need to wrap his defun's with a check to see whether a function is already defined and only do the defun if the function hasn't already been defined. I plan to remove all the example values and defuns from anything.el (except for anything-sources), since Tassilo does a great job with anything-config and there is no need to duplicate stuff. This will solve some of the interaction problems I think. ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
Hi, On Aug 3, 10:08 pm, [EMAIL PROTECTED] wrote: The last file I selected with a search pattern of anyt was anything.el (with a count of 2 times using that pattern) but the file I've selected most frequently is anything-config.el (with a count of 4 times using that pattern) so I would have thought that anything- config.el would show up first when I call up anything and enter a pattern of anyt. Yes, that's exactly how it should work and it works like this for me. Is it still not working correctly or did I misunderstand what was intended? I was writing the code this afternoon during a programming course while I was simultaneously working on the task given by the instructor, so yes, it's possible there are still bugs in it. :) It's hot off the presses and is not tested extensively. However, the code is not complex, so it should work more or less correctly. I don't know why you get these results. Hopefully, someone else tries it too, so that we have more information. BTW, the heart of the sorting is the function anything-adaptive-sort which sorts the candidates according to variable anything-adaptive- history. It's not a long function, so maybe someone who understands enough lisp does a peer review and discovers quickly what the problem is which I miss. /Tamas ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
Hi Tamas, On Aug 3, 10:38 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I tried it and it didn't work for me either. :) Aha, very sneaky way to check whether anyone had tried out the code! ;-) I left a bug in it which I now fixed. It should work now. I uploaded it to Emacs Wiki temporarily until Tassilo decides if it's worthy of inclusion into anything-config.el I tried out the code on Emacs Wiki and I'm not sure if it's working the way I thought it would work. For example, I selected a number of different files from the file history and this is the contents of the anything-adaptive-history variable: ((File Name History (~/lisp/emacs/site-lisp/anything.el (anyt . 2) ( . 2)) (~/lisp/emacs/site-lisp/anything-config.el (anyt . 4) ( . 4)) (~/.emacs ( . 1))) (Buffers (anything.el ( . 1 The last file I selected with a search pattern of anyt was anything.el (with a count of 2 times using that pattern) but the file I've selected most frequently is anything-config.el (with a count of 4 times using that pattern) so I would have thought that anything- config.el would show up first when I call up anything and enter a pattern of anyt. However, this is what I get: File Name History 1 - ~/list/emacs/site-lisp/anything.el 2 - ~/list/emacs/site-lisp/anything-config.el 3 - ~/list/emacs/site-lisp/anything.el 4 - ~/list/emacs/site-lisp/anything-config.el 5 - ~/list/emacs/site-lisp/anything.el 6 - ~/.anything_adaptive_history 7 - ~/list/emacs/site-lisp/anything-config.el etc. Is it still not working correctly or did I misunderstand what was intended? - Bill ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
On Aug 3, 1:31 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, On Aug 3, 10:08 pm, [EMAIL PROTECTED] wrote: The last file I selected with a search pattern of anyt was anything.el (with a count of 2 times using that pattern) but the file I've selected most frequently is anything-config.el (with a count of 4 times using that pattern) so I would have thought that anything- config.el would show up first when I call up anything and enter a pattern of anyt. Yes, that's exactly how it should work and it works like this for me. Is it still not working correctly or did I misunderstand what was intended? I was writing the code this afternoon during a programming course while I was simultaneously working on the task given by the instructor, so yes, it's possible there are still bugs in it. :) It's hot off the presses and is not tested extensively. However, the code is not complex, so it should work more or less correctly. I don't know why you get these results. Hopefully, someone else tries it too, so that we have more information. BTW, the heart of the sorting is the function anything-adaptive-sort which sorts the candidates according to variable anything-adaptive- history. It's not a long function, so maybe someone who understands enough lisp does a peer review and discovers quickly what the problem is which I miss. Oops, looks like I forgot to do: (setq anything-filtered-candidate-transformers '((file . anything-adaptive-sort))) after loading anything-adaptive.el. I guess I thought I had since the history was showing up. With some limited testing, anything now seems to be returning things according to the history values. However, if anything-filtered-candidate-transformers is nil, there shouldn't be any history written. If this code is added to anything-config.el, Tassilo will probably want to modify it so that the history is only written when the user has activated the filtered candidate transformer functionality. - Bill ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: Hi all, the adaptive sorting thingy sounds great and of course I'm happy to include it. But this weekend is full of other tasks and I'm not even sure if I have any network connection till monday, so this probably has to wait a bit. I plan to remove all the example values and defuns from anything.el (except for anything-sources), since Tassilo does a great job with anything-config and there is no need to duplicate stuff. Ah, that would be great. After Bill told me that he had problems with the latest changes in anything-config.el (I've removed the eval-after-load [which was malformed, anyway] and required anything as last operation in the file) I found out that I can choose between cancer and pestilence: - If I load anything first, I cannot overwrite defvars, which is bad. - If I load anything after anything-config, all the defuns will be redefined by anything which bad, too. So in either case there are problems. So if you remove the duplicate functions that would solve all problems for us. Could you please copy functions that are needed by `anything-sources', e.g. `anything-buffer-list' from anything-config? I'm not sure, but I think that's the only one. My version puts the current buffer to the back of the list, so that you can easily switch between two buffers without any keys except invoking anything and RET (assuming the buffer source comes first). I'll upload a new anything-config.el in 5 minutes that has a correctly working eval-after-load to ensure that anything is loaded after anything-config. Everything should work fine when the functions that are duplicated are removed from anything.el. Have a nice weekend! Tassilo -- If programmers deserve to be rewarded for creating innovative programs, by the same token they deserve to be punished if they restrict the use of these programs. (Richard M. Stallman) ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
On Aug 3, 11:15 pm, [EMAIL PROTECTED] wrote: With some limited testing, anything now seems to be returning things according to the history values. Glad it's working. Do you like it? :) However, if anything-filtered-candidate-transformers is nil, there shouldn't be any history written. If this code is added to anything-config.el, Tassilo will probably want to modify it so that the history is only written when the user has activated the filtered candidate transformer functionality. Well, anything-filtered-candidate-transformers is supposedly a generic feature (though admittedly it was added to support dynamic candidate sorting), so saving of history shouldn't depend on its value being non- nil. I think there should be a function in anything-config.el which the user has to call explicitly if he wants the history recording feature activated. Like (anything-iswitchb-setup) for iswitchb in anything.el. /Tamas ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
Re: ;;; anything.el --- open anything
Hi, On Aug 3, 11:28 pm, Tassilo Horn [EMAIL PROTECTED] wrote: So if you remove the duplicate functions that would solve all problems for us. Could you please copy functions that are needed by `anything-sources', e.g. `anything-buffer-list' from anything-config? The only function was anything-buffer-list, and I copied it into anything-sources with a lambda. I'm not sure, but I think that's the only one. My version puts the current buffer to the back of the list, so that you can easily switch between two buffers without any keys except invoking anything and RET (assuming the buffer source comes first). I already used my simpler version in anything.el, but it shouldn't matter, since any serious user should consult the configs in anything- config anyway. I'll upload a new anything-config.el in 5 minutes that has a correctly working eval-after-load to ensure that anything is loaded after anything-config. Everything should work fine when the functions that are duplicated are removed from anything.el. The new version is uploaded to emacs wiki. BTW, shouldn't all symbols (except those overwriting anything.el values) in anything-config be prefixed with anything-config- instead of simply anything- ? If they had been then functions wouldn't have overdefined each other in the first place and it could prevent possible clashes of symbols in the future. /Tamas ___ gnu-emacs-sources mailing list gnu-emacs-sources@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources