[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode f359fd01c5 12/22: Add predicate to "around" lat
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/julia-mode f359fd01c5 12/22: Add predicate to "around" latex symbol completion |
|
Date: |
Thu, 4 May 2023 11:00:52 -0400 (EDT) |
branch: elpa/julia-mode
commit f359fd01c5ad673990cb4bccc6895e5b2dbd2785
Author: Adam Beckmeyer <adam_gpg@thebeckmeyers.xyz>
Commit: Adam Beckmeyer <adam_gpg@thebeckmeyers.xyz>
Add predicate to "around" latex symbol completion
This predicate ensures that the symbol you're trying to complete is a
substring of the
completion candidates. With "before" completion this isn't necessary since
there isn't
potential for the symbol you're trying to complete containing text that
isn't intended to be
completed.
This commit also includes some refactors for clarity and DRY.
---
julia-mode.el | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/julia-mode.el b/julia-mode.el
index 953944aa47..f6f409c3dd 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -833,28 +833,36 @@ If there is not a LaTeX-like symbol at point, return nil."
(forward-char))
(point)))
-;; Sometimes you want to complete a symbol point is in middle of
+;; Sometimes you want to complete a symbol `point' is in middle of
(defun julia-mode-latexsub-completion-at-point-around ()
"Return completion for LaTeX-like symbol around point.
Suitable for use in `completion-at-point-functions'."
- (let ((beg (julia--latexsub-start-symbol)))
- (when beg
- (list beg (julia--latexsub-end-symbol) julia-mode-latexsubs
- :exclusive 'no
- :annotation-function (lambda (s)
- (concat " " (gethash s
julia-mode-latexsubs)))
- :exit-function (julia--latexsub-exit-function beg)))))
+ (when-let ((beg (julia--latexsub-start-symbol)))
+ (let* ((end (julia--latexsub-end-symbol))
+ (buffer-symbol (buffer-substring beg end))
+ ;; Depending on `completion-styles', completion may try to complete
+ ;; e.g. "\hat_mean" to "\hat". This predicate ensures that any
completion candidates
+ ;; must start with "\hat_mean".
+ (pred (lambda (candidate _candidate-completion)
+ (string= buffer-symbol
+ (substring candidate
+ 0 (min (length candidate) (length
buffer-symbol)))))))
+ (julia--latexsub-capf-list beg end pred))))
;; Sometimes you want to complete a symbol point is at end of (with no space
after)
(defun julia-mode-latexsub-completion-at-point-before ()
"Return completion for LaTeX-like symbol before point.
Suitable for use in `completion-at-point-functions'."
- (let ((beg (julia--latexsub-start-symbol)))
- (when beg
- (list beg (point) julia-mode-latexsubs :exclusive 'no
- :annotation-function (lambda (s)
- (concat " " (gethash s
julia-mode-latexsubs)))
- :exit-function (julia--latexsub-exit-function beg)))))
+ (when-let ((beg (julia--latexsub-start-symbol)))
+ (julia--latexsub-capf-list beg (point) nil)))
+
+(defun julia--latexsub-capf-list (beg end pred)
+ "Return list suitable for use in `completion-at-point-functions' of
latexsubs."
+ (list beg end julia-mode-latexsubs :exclusive 'no
+ :annotation-function (lambda (s)
+ (concat " " (gethash s julia-mode-latexsubs)))
+ :exit-function (julia--latexsub-exit-function beg)
+ :predicate pred))
(defun julia--latexsub-exit-function (beg)
"Return function to be used as `completion-extra-properties'
`:exit-function'.
@@ -870,8 +878,9 @@ buffer where the LaTeX symbol starts."
;; <https://github.com/abo-abo/swiper/issues/2345>). Instead of
automatic
;; expansion, user can either enable `abbrev-mode' or call
`expand-abbrev'.
(when-let (((eq status 'finished))
- (symb (abbrev-symbol name julia-latexsub-abbrev-table)))
- (abbrev-insert symb name beg (point))))
+ (symb (abbrev-symbol name julia-latexsub-abbrev-table))
+ (end (+ beg (length name))))
+ (abbrev-insert symb name beg end)))
#'ignore))
;; company-mode doesn't work via `indent-for-tab-command'. In order to have a
consistent
- [nongnu] elpa/julia-mode 8078bb9d88 01/22: Add completion-at-point functions for completing LaTeX strings, (continued)
- [nongnu] elpa/julia-mode 8078bb9d88 01/22: Add completion-at-point functions for completing LaTeX strings, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 307b4afa9a 03/22: Create julia-mode-abbrev-table filled with latexsub abbrevs, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode d52cb3e885 10/22: Provide alternative to indent-for-tab-command for use with company, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 77ff4f1146 15/22: comment code, fix docstring width, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode d684bf172a 17/22: further byte compilation docstring warning fixes, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 759e8a8e57 18/22: Merge branch 'master' into tp/find-latexsub-end, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode c87949315f 02/22: Remove hack for indentation in strings, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 4d2047666f 04/22: Remove old latexsub implementation, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 0160fecf90 05/22: Override TAB to do completion in julia-mode buffers, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode f92227a87f 09/22: Fix whitespace, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode f359fd01c5 12/22: Add predicate to "around" latex symbol completion,
ELPA Syncer <=
- [nongnu] elpa/julia-mode 347c5c11c5 14/22: cleanup tests, bit more verbose to compare matched string, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 74e13dc460 16/22: use cl-flet, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 15326d6992 08/22: Remove extraneous -mode suffix from julia-- functions, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 016721004c 19/22: Merge pull request #185 from JuliaEditorSupport/tp/find-latexsub-end, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 8f3afcb99e 21/22: ignore warnings on snaphot, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode f854352d76 11/22: Fix byte-compilation warnings for company-integration code, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 7e301f4414 22/22: Merge pull request #186 from tpapp/tp/remove-emacs-25, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode d2b28644d2 06/22: Stop overriding regex in julia-mode-abbrev-table, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode c8e33f81fa 13/22: Use a hash table to look up where symbols end., ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode a39c9d2dd3 07/22: Automatically substitute LaTeX symbols after completion., ELPA Syncer, 2023/05/04