Generic index mode for Emacs
Emacs Lisp
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.dir-locals.el
.gitignore
README
el-index.el

README

el-index --- Generic index mode for Emacs

-------------------------------------------------------------------------------
1. About
-------------------------------------------------------------------------------

Displays list of given items. By default you can configure select, delete and
rename actions. Other custom actions may be applied via local keymap

Code was based on bookmark.el which can be found in Emacs distribution

-------------------------------------------------------------------------------
2. Installation
-------------------------------------------------------------------------------

Put `el-index' project into your load path

-------------------------------------------------------------------------------
3. Usage
-------------------------------------------------------------------------------
3.1 Initialization
-------------------------------------------------------------------------------

(require 'el-index/el-index)

Invoke mode by calling `el-index-display' passing buffer name, items list and
list of functions that will take care of: writing item name, selecting, renaming,
deleting and reload index list.
See following example:

(setq sample-items-group1
  '((first . optional)
    (second . optional)
    (third . optional)))

(setq sample-items-group2
  '((first2 . optional)
    (second2 . optional)
    (third2 . optional)))

(setq sample-items
  (list (cons "First Group" sample-items-group1)
    (cons "Second Group" sample-items-group2)))

(setq index-actions
  '((write . (lambda (item)
        (insert (symbol-name (car item)))))
    (select . (lambda (item)
        (message "%S selected" (car item))
        (quit-window)))
    (rename . (lambda (item newname)
        (if (and newname (not (equal newname "")))
          (setcar item (intern newname))
          (message "No new name given"))))
    (delete . (lambda (item)
        (setq sample-items-group1 (delq item sample-items-group1))
        (setq sample-items-group2 (delq item sample-items-group2))))
    (reload . sample-index-display)))

(defun sample-index-display ()
  (el-index-display "Sample index" sample-items index-actions))

(sample-index-display)

-------------------------------------------------------------------------------
3.2 Interaction
-------------------------------------------------------------------------------

Default keyboard bindings:

RET -- Select item.

r -- Rename item (prompts for new name).

d -- Mark item to be deleted, and move down.
C-d -- Mark item to be deleted, and move up.

x -- Delete items marked with `D.

u -- Remove all kinds of marks from current line.

You can add extra bindings with `local-key-set' when mode is loaded.