[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/jinx 61144055e8: jinx-languages: Group by dictionary pr
From: |
ELPA Syncer |
Subject: |
[elpa] externals/jinx 61144055e8: jinx-languages: Group by dictionary provider |
Date: |
Tue, 19 Nov 2024 12:58:21 -0500 (EST) |
branch: externals/jinx
commit 61144055e8ce445568baa19302f4af60e15a2e6d
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
jinx-languages: Group by dictionary provider
---
CHANGELOG.org | 1 +
jinx-mod.c | 6 ++++--
jinx.el | 51 +++++++++++++++++++++++++++++----------------------
3 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 28b42de9a2..f9256ce3ac 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -5,6 +5,7 @@
* Development
- Require Emacs 28.1.
+- ~jinx-languages~: Group dictionaries by dictionary provider.
* Version 1.10 (2024-07-23)
diff --git a/jinx-mod.c b/jinx-mod.c
index 9af48eb869..d08c86fb05 100644
--- a/jinx-mod.c
+++ b/jinx-mod.c
@@ -108,13 +108,15 @@ static emacs_value jinx_describe(emacs_env* env,
ptrdiff_t jinx_unused(nargs),
}
static void jinx_langs_cb(const char* const lang_tag,
- const char* const jinx_unused(provider_name),
+ const char* const provider_name,
const char* const jinx_unused(provider_desc),
const char* const jinx_unused(provider_file),
void* data) {
emacs_env* env = ((emacs_env**)data)[0];
((emacs_value*)data)[1] = jinx_cons(env,
- jinx_str(env, lang_tag),
+ jinx_cons(env,
+ jinx_str(env, lang_tag),
+ jinx_str(env,
provider_name)),
((emacs_value*)data)[1]);
}
diff --git a/jinx.el b/jinx.el
index 8909ffd77e..2247a87597 100644
--- a/jinx.el
+++ b/jinx.el
@@ -776,7 +776,7 @@ The word will be associated with GROUP and get a prefix
key."
(format #(" (%s)" 0 5 (face jinx-key)) (string-trim prefix))
(get-text-property 0 'jinx--suffix cand)))
-(defun jinx--correct-group (word transform)
+(defun jinx--group (word transform)
"Group WORD during completion, TRANSFORM candidate if non-nil."
(if transform
word
@@ -784,15 +784,15 @@ The word will be associated with GROUP and get a prefix
key."
(defun jinx--correct-table (suggestions)
"Completion table for SUGGESTIONS."
- (lambda (str pred action)
- (if (eq action 'metadata)
- `(metadata (category . jinx)
- (display-sort-function . ,#'identity)
- (cycle-sort-function . ,#'identity)
- (group-function . ,#'jinx--correct-group)
- (affixation-function . ,#'jinx--correct-affixation)
- (annotation-function . ,#'jinx--correct-annotation))
- (complete-with-action action suggestions str pred))))
+ (let ((md `(metadata (category . jinx)
+ (display-sort-function . ,#'identity)
+ (cycle-sort-function . ,#'identity)
+ (group-function . ,#'jinx--group)
+ (affixation-function . ,#'jinx--correct-affixation)
+ (annotation-function . ,#'jinx--correct-annotation))))
+ (lambda (str pred action)
+ (if (eq action 'metadata) md
+ (complete-with-action action suggestions str pred)))))
(cl-defun jinx--correct-overlay (overlay &key info initial)
"Correct word at OVERLAY.
@@ -886,6 +886,24 @@ Optionally show prompt INFO and insert INITIAL input."
(when (re-search-forward "\\<\\w+\\>" nil t)
(cons (match-beginning 0) (match-end 0)))))))
+(defun jinx--read-languages ()
+ "Read languages via `completing-read-multiple'."
+ (jinx--load-module)
+ (let ((langs (delete-dups
+ (cl-loop for (l . p) in (jinx--mod-langs) collect
+ (propertize l 'jinx--group (format "Provider %s"
p)))))
+ (md `(metadata (group-function . ,#'jinx--group))))
+ (string-join
+ (or (completing-read-multiple
+ (format "Change languages (%s): "
+ (string-join (split-string jinx-languages) ", "))
+ (lambda (str pred action)
+ (if (eq action 'metadata) md
+ (complete-with-action action langs str pred)))
+ nil t)
+ (user-error "No languages selected"))
+ " ")))
+
;;;; Save functions
(defun jinx--save-personal (save key word)
@@ -934,18 +952,7 @@ by whitespace. When called interactively, the language
codes are
read via `completing-read-multiple'. If the prefix argument
GLOBAL is non-nil, the languages are changed globally for all
buffers. See also the variable `jinx-languages'."
- (interactive
- (list
- (progn
- (jinx--load-module)
- (string-join
- (or (completing-read-multiple
- (format "Change languages (%s): "
- (string-join (split-string jinx-languages) ", "))
- (delete-dups (jinx--mod-langs)) nil t)
- (user-error "No languages selected"))
- " "))
- current-prefix-arg))
+ (interactive (list (jinx--read-languages) current-prefix-arg))
(unless jinx-mode (jinx-mode 1))
(cond
(global
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/jinx 61144055e8: jinx-languages: Group by dictionary provider,
ELPA Syncer <=