Skip to content

Commit

Permalink
feat: keymap with new entries/aliases, add doc on new features
Browse files Browse the repository at this point in the history
  • Loading branch information
LionyxML committed Nov 3, 2023
1 parent 5065172 commit 0605faa
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 24 deletions.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,78 @@ Create a markdown table from the active region or the current buffer using Ellam

Summarize a webpage fetched from a URL using Ellama.

### ellama-code-complete

Alias to the `ellama-complete-code` function.

### ellama-code-add

Alias to the `ellama-add-code` function.

### ellama-code-edit

Alias to the `ellama-change-code` function.

### ellama-code-improve

Alias to the `ellama-enhance-code` function.

### ellama-improve-wording

Alias to the `ellama-enhance-wording` function.

### ellama-improve-grammar

Alias to the `ellama-enhance-grammar-spelling` function.

### ellama-improve-conciseness

Alias to the `ellama-make-concise` function.

### ellama-make-format

Alias to the `ellama-render` function.

### ellama-ask-interactive
Alias to the `ellama-ask` function.


## Keymap

Here is a table of keybindings and their associated functions in
Ellama, using the `C-x e` prefix:

| Keymap | Function | Description |
|--------|----------------------------|------------------------------------|
| "c c" | ellama-code-complete | Code complete |
| "c a" | ellama-code-add | Code add |
| "c e" | ellama-code-edit | Code edit |
| "c i" | ellama-code-improve | Code improve |
| "c r" | ellama-code-review | Code review |
| "s s" | ellama-summarize | Summarize |
| "s w" | ellama-summarize-webpage | Summarize webpage |
| "i w" | ellama-improve-wording | Improve wording |
| "i g" | ellama-improve-grammar | Improve grammar and spelling |
| "i c" | ellama-improve-conciseness | Improve conciseness |
| "m l" | ellama-make-list | Make list |
| "m t" | ellama-make-table | Make table |
| "m f" | ellama-make-format | Make format |
| "a a" | ellama-ask-about | Ask about |
| "a i" | ellama-ask-interactive | Chat with ellama (Interactive) |
| "t" | ellama-translate | Translate the selected region |
| "d" | ellama-define-word | Define selected word |


## Configuration

The following variables can be customized for the Ellama client:

- `ellama-buffer`: The default Ellama buffer name.
- `ellama-enable-break-lines`: Enable visual-mode to \*\*ellama\*\*
buffers, hence avoiding the need of horizontal scrolling on long
lines.
- `ellama-enable-keymap`: Enable the Ellama keymap.
- `ellama-keymap-prefix`: The keymap prefix for Ellama.
- `ellama-user-nick`: The user nick in logs.
- `ellama-assistant-nick`: The assistant nick in logs.
- `ellama-buffer-mode`: The major mode for the Ellama logs buffer.
Expand Down
78 changes: 54 additions & 24 deletions ellama.el
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,33 @@
(define-key global-map (kbd ellama-keymap-prefix) ellama-keymap)

(let ((key-commands
'(("a a" ellama-ask-about "Ask about selected region")
("m c" ellama-make-concise "Better text")
("c h" ellama-chat "Chat with Ellama")
("d w" ellama-define-word "Define selected word")
("c r" ellama-code-review "Code-review selected code")
("s m" ellama-summarize "Summarize selected region")
("s w" ellama-summarize-webpage "Summarize a web page")
("t" ellama-translate "Translate the selected region")
("r" ellama-render "Convert text to a specified format")
("e g s" ellama-enhance-grammar-spelling "Enhance grammar and spelling")
("e w" ellama-enhance-wording "Enhance wording")
("e c" ellama-enhance-code "Enhance selected code")
("c c" ellama-change-code "Replace selected code")
("m l" ellama-make-list "Create a markdown list")
("m t" ellama-make-table "Generate a markdown table")
("c o" ellama-complete-code "Complete selected code")
("a c" ellama-add-code "Add new code based on description"))))
(dolist (key-command key-commands)
(let ((key (car key-command))
(function (cadr key-command)))
(eval `(define-key ellama-keymap (kbd ,key) ',function))))))
'(
;; code
("c c" ellama-code-complete "Code complete")
("c a" ellama-code-add "Code add")
("c e" ellama-code-edit "Code edit")
("c i" ellama-code-improve "Code improve")
("c r" ellama-code-review "Code review")
;; summarize
("s s" ellama-summarize "Summarize")
("s w" ellama-summarize-webpage "Summarize webpage")
;; improve
("i w" ellama-improve-wording "Improve wording")
("i g" ellama-improve-grammar "Improve grammar and spelling")
("i c" ellama-improve-conciseness "Improve conciseness")
;; make
("m l" ellama-make-list "Make list")
("m t" ellama-make-table "Make table")
("m f" ellama-make-format "Make format")
;; ask
("a a" ellama-ask-about "Ask about")
("a i" ellama-ask-interactive "Chat with ellama")
;; other
("t" ellama-translate "Translate the selected region")
("d" ellama-define-word "Define selected word"))))
(dolist (key-command key-commands)
(define-key ellama-keymap (kbd (car key-command)) (cadr key-command)))))


(defcustom ellama-keymap-prefix "C-x e"
"Key sequence for Ellama Commands."
Expand All @@ -146,9 +152,6 @@
;; If ellama-enable-keymap is nil, remove the key bindings
(define-key global-map (kbd ellama-keymap-prefix) nil))))




(defun ellama-stream (prompt &rest args)
"Query ellama for PROMPT.
ARGS contains keys for fine control.
Expand Down Expand Up @@ -266,6 +269,33 @@ In BUFFER at POINT will be inserted result between PREFIX and SUFFIX."
;;;###autoload
(defalias 'ellama-ask 'ellama-chat)

;;;###autoload
(defalias 'ellama-code-complete 'ellama-complete-code)

;;;###autoload
(defalias 'ellama-code-add 'ellama-add-code)

;;;###autoload
(defalias 'ellama-code-edit 'ellama-change-code)

;;###autoload
(defalias 'ellama-code-improve 'ellama-enhance-code)

;;;###autoload
(defalias 'ellama-improve-wording 'ellama-enhance-wording)

;;;###autoload
(defalias 'ellama-improve-grammar 'ellama-enhance-grammar-spelling)

;;;###autoload
(defalias 'ellama-improve-conciseness 'ellama-make-concise)

;;;###autoload
(defalias 'ellama-make-format 'ellama-render)

;;;###autoload
(defalias 'ellama-ask-interactive 'ellama-ask)

;;;###autoload
(defun ellama-ask-about ()
"Ask ellama about selected region or current buffer."
Expand Down

0 comments on commit 0605faa

Please sign in to comment.