Yet another context sensitive completion framework. The idea is to analyze the text at point, beginning of line etc. to generate completions. The aim is also not to just return completions but also documentation or any other helpful information.
Invoking the command vj-complete when the cursor is after `string-ma' causes display of the *vj-complete* buffer.
With completion-ui adapter
Repeated calls to vj-complete would insert `string-make-multi-byte', `string-make-unibyte', etc. You get the picture. Direct selection can be done with an argument to the vj-complete command. For example C-2 M-x vj-complete RET would insert the `string-match' completion.
Installation:
(require 'vj-complete-elisp) ;; currently steals C-t
It has special support for completion of functions, require
and add-hook.
Installation of C# support:
c:/src/proj1/AzDriver.dll c:/src/proj1/AzDriverTest.exe c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.XML.dll
(require 'vj-complete-csharp)
(setq vj-complete-csharp-filename "c:/dir/to/inputfile/assembly_tags")
(csharp-reload-tags)
C# stuff that kinda works. -!- marks point where you begin completion (press C-t)
using System.C-!-
Driver driver = new Driver();
driver.Conn-!-
string s = "123";
s.Length.ToStri-!-
(new String()).Le-!-
(driver as PtzDriver).-!-
Console.Write-!-
Exception ex = new Exception();
ex.InnerException.Source.ToSt-!- // <-- Chaining works!
[Sec-!-
class Test {..
SomeClass c = -!- // inserts "new SomeClass" and shows contructor signatures
If you want to add support for mode then here is the boilerplate code:
(add-hook 'foo-mode-hook 'vj-complete-foo-setup)
(defun vj-complete-foo-setup ()
(setq vj-complete-get-completions-function
'vj-complete-get-foo-completions)
(local-set-key (kbd "C-t") 'vj-complete))
;; Return a list of completion records (COMPLETION DOCLINE TYPECODE)
(defun vj-complete-get-foo-completions ()
(setq vj-complete-current-begin-point
(save-excursion
(skip-chars-backward "A-Za-z_0-9-" (point-at-bol)) ;; your symbol regex
(point)))
;; -- your code here --
;; Find completions for the prefix:
;; (buffer-substring-no-properties vj-complete-current-begin-point (point))
;; --
(list '("name" "doc" "F") '("name2" "doc2" "V")))
;; Optional "hook". Called after creating the completion buffer.
;; (setq vj-complete-insert-header-function 'vj-complete-foo-insert-header)
;; Defining projects
;; Create a project containing all elisp files in two directories
(vps-add-project "my_elisp"
'((dirs ("c:/vjo/setup/emacs/" "c:/tools/emacs-21.3/site-lisp"))
(ext ("el"))
(file-cache-add t))) ;; also add to file cache
;; Create a project with all the files in load-path
(vps-add-project "Emacs_load-path" `((dirs ,load-path) (ext ("el"))))
;; "Recurse" directories via 'rdirs
(vps-add-project "C++" '(
(rdirs ("/src/project-root" "/usr/include"))
(dirs ("~/stuff"))
(ext ("c" "cpp" "h"))
))
Open a file and run vps-auto-change-project (M-i M-i) to
autodetect the correct project. If the file belongs to more than one
project you must select amongst the possible projects. Use
vps-change-project (M-i c) to change to a specific
project. To quickly open a file in the project
use vps-list-dirs (M-i l) and do a search for the file and
then press RET twice to open it.TAGS files are automatically built and rebuilt when they are too old (Configure the timeouts with M-x customize-group RET vps RET). You can force a rebuild with vps-make-tags.
The hook function vps-change-project-hook is called when the project is changed. You can use vps-project-name, vps-dirs and vps-valid-dirs in your hook function. It is also possible to set a function to be called in the project definition (via the symbol setup-function).
M-i M-i vps-auto-change-project
M-i M-g vps-grep
M-i c vps-change-project
M-i d vps-virtual-dired
M-i g vps-grep-ignore-case
vps-grep
M-i i vps-auto-change-project
M-i l vps-list-dirs
M-i s vps-grep-via-index
vps-make-tags
vps-make-ctags
vps-shell-command-in-dirs
Installation:
(require 'vps) (vps-init "\M-i") ;; \M-i is default key-prefix, so you could do (vps-init) (vps-add-project ...)Example of vps-grep (M-i g) / vps-grep-ignore-case (M-i M-g) in action:
It uses an external program written in Perl.
Bind grep of current symbol to a key
(global-set-key [M-f2] (lambda ()
(interactive) (vps-grep (current-word))))
Note that it does not ignore case, which is useful when
getting words and symbols from buffers.
To have the current project name in the title bar, use something like:
(setq frame-title-format
'("" invocation-name " " " %f [" vps-project-name "]"))
An anything source for vps:
(defvar anything-source-vps-files
'((name . "Project Files")
(candidates . (lambda ()
(when vps-project-name
(if (not (file-exists-p (vps-filelist-filename)))
(vps-write-filelist))
(start-process "anything-source-vps-files" nil
"grep" "-i" (replace-regexp-in-string "^-" "."
anything-pattern)
(vps-filelist-filename)))))
(type . file)
(requires-pattern . 4))
"Source for retrieving files (cached) vps filelist.")
A helm source for vps:
(defvar helm-source-vps-files
'((name . "Project Files")
(init . (lambda ()
(with-current-buffer (helm-candidate-buffer 'global)
(when (and vps-project-name
(file-exists-p (vps-filelist-filename)))
(insert-file-contents (vps-filelist-filename))))))
(requires-pattern . 3)
(candidates-in-buffer)
(candidate-number-limit . 999)
(type . file)))
.
Here is my find-tag wrapper that can be pressed repeatedly to go to
next tag "hit". Also it will automatically change to the correct vps
project (or prompt if the current file belongs to multiple
projects). I suggest binding it to M-:
(defun vj-find-tag ()
"My find-tag wrapper for easy repetition (VJO 2003).
Call `find-tag' with current word first time and after that call
find-tag with NEXT-P set to t (if called repeatedly)"
(interactive)
(vps-auto-change-project t) ;can change last-command
(if (eq last-command 'vj-find-tag)
(find-tag nil t)
(find-tag (current-word) current-prefix-arg)))
Combine
completion-ui.el
with
sqlplus.el