Emacs Code by Vagn Johansen

vj-complete | vps | vj-sqlplus-complete | context-info | org-import-calendar | My emacs config | ^

vj-complete

vj-complete.tar.gz beta (requires Emacs 22.1)
  • 2008-06-28 Interface to dropdown-list.el (bind the function vj-complete-dropdown).
    More robust elisp completion: Getting completions for defalias'ed functions could throw error.
  • 2008-06-21 Added vj-complete-completion-ui.el to integrate with completion-ui.el
  • 2008-04-21 C# current class member completion
  • 2008-04-19 C# Generics support. C# attribute class completion
  • 2007-09-11 Added C# completion code (beta quality)
  • 2007-07-27 Completion insert no longer deletes prefix in original buffer when the common part only differs in case. The original casing is also preserved
  • 2007-07-12 Fixed windows handling

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:

(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)

          



vps - Directory Sets

vps.tar.gz (Probably requires Emacs 22.1). Requires the touch command to be on your system. Requires Perl for doing clever grep searches. Bleeding edge version can be found on github
  • 2013-04-13 Added vps-write-file-list-hook
  • 2012-09-19 RET in vps-list-dirs immediately opens file.
  • 2010-01-30 Small fix in vps-virtual-dired.
  • 2009-04-14 Better support for spaces in directory names.
  • 2009-04-10 Make it possible to set vps-project-dir to a directory containing a ~.
  • 2009-04-08 Allow spaces in directory name. Store filelist with 'raw-text coding system. New interactive function vps-compile-command.
  • 2007-09-16 Fast grepping via inverse index database (New function vps-make-index)
  • 2003-2007: Numerous changes
A Projects Settings Package. Define a set of files by specifying a list of specific directories ('dirs) and list of file extensions ('ext) . Toplevel directories are supported via 'rdirs (the directory set contain all subdirectories).
;; 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:
(Note the friendly output format)

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)))



vj-sqlplus-complete

vj-sqlplus-complete.el

Combine completion-ui.el with sqlplus.el


context-info

.. in progress ..
(use header-line-format to show info about (point))


org-import-calendar

org-import-calendar.el for gnus. When a text/calendar part is detected a small org snippet is copied to the kill-ring. Added simplistic support for get calendar data from a winmail.dat




(A Part Of) My Emacs Configuration

.. is available on
github