emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ellama 7331e5bb55 09/11: Merge pull request #7 from Lio


From: ELPA Syncer
Subject: [elpa] externals/ellama 7331e5bb55 09/11: Merge pull request #7 from LionyxML/feat/custom_keymap_and_line_breaking
Date: Mon, 18 Dec 2023 00:57:45 -0500 (EST)

branch: externals/ellama
commit 7331e5bb559c1ff34390244ee53629a66219effb
Merge: 11f601db8e ed77311d57
Author: Sergey Kostyaev <s-kostyaev@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #7 from LionyxML/feat/custom_keymap_and_line_breaking
    
    feat/custom_keymap
---
 README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
 ellama.el | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+)

diff --git a/README.md b/README.md
index 1f168519cc..aff2d0f6ce 100644
--- a/README.md
+++ b/README.md
@@ -145,11 +145,76 @@ 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)     |
+| "a l"  | ellama-ask-line            | Ask about current line             |
+| "a s"  | ellama-ask-selection       | Ask about selection                |
+| "t t"  | ellama-translate           | Text translate                     |
+| "t c"  | ellama-complete            | Text complete                      |
+| "d w"  | ellama-define-word         | Define word                        |
+
 ## Configuration
 
 The following variables can be customized for the Ellama client:
 
 - `ellama-buffer`: The default Ellama buffer name.
+- `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.
diff --git a/ellama.el b/ellama.el
index 455085a745..1218b54428 100644
--- a/ellama.el
+++ b/ellama.el
@@ -97,6 +97,62 @@
   (rx (minimal-match
        (literal "```") (zero-or-more anything))))
 
+(defun ellama-setup-keymap ()
+  "Set up the Ellama keymap and bindings."
+  (interactive)
+  (defvar ellama-keymap (make-sparse-keymap)
+    "Keymap for Ellama Commands")
+
+  (define-key global-map (kbd ellama-keymap-prefix) ellama-keymap)
+
+  (let ((key-commands
+          '(
+               ;; 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 "Ask interactively")
+                  ("a l" ellama-ask-line "Ask about current line")
+                  ("a s" ellama-ask-selection "Ask about selection")
+                  ;; text
+                  ("t t" ellama-translate "Text translate")
+                  ("t c" ellama-complete "Text complete")
+                          ;; define
+                  ("d w" ellama-define-word "Define 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."
+  :type 'string
+  :group 'ellama)
+
+(defcustom ellama-enable-keymap t
+  "Enable or disable Ellama keymap."
+  :type 'boolean
+  :group 'ellama
+  :set (lambda (symbol value)
+         (set symbol value)
+         (if value
+             (ellama-setup-keymap)
+           ;; 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.
@@ -236,6 +292,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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]