[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/j-mode 3509c2d 15/56: Added branch search function for mor
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/j-mode 3509c2d 15/56: Added branch search function for more intelligent symbol detection |
Date: |
Sun, 29 Aug 2021 11:20:46 -0400 (EDT) |
branch: elpa/j-mode
commit 3509c2d3ffd813ff1c4a2cb7a731c2890089cfb4
Author: Zachary Elliott <zach@nyu.edu>
Commit: Zachary Elliott <zach@nyu.edu>
Added branch search function for more intelligent symbol detection
---
j-help.el | 83 +++++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 60 insertions(+), 23 deletions(-)
diff --git a/j-help.el b/j-help.el
index 6ef9ba9..dd4b04d 100644
--- a/j-help.el
+++ b/j-help.el
@@ -5,14 +5,23 @@
;;
;; Authors: Zachary Elliott <ZacharyElliott1@gmail.com>
;; URL: http://github.com/zellio/j-mode
-;; Version: 0.0.1
+;; Version: 1.0.0
;; Keywords: J, Languages
;; This file is not part of GNU Emacs.
;;; Commentary:
+;; j-help provides access to the J software vocabulary via two functions
+;; j-help-lookup-symbol and j-help-lookup-symbol-at-point. j-help-look-symbol
+;; takes one string argument ( generally via the mini-buffer ) which it then
+;; looks up. j-help-lookup-symbol-at-point attempts to determine which symbol
+;; is under your cursor and then passes that to j-help-lookup-symbol.
;;
+;; The module provides the following key bindings for convenience
+;;
+;; * <kbd>C-c h</kbd> runs j-help-lookup-symbol
+;; * <kbd>C-c C-h</kbd> j-help-lookup-symbol-at-point
;;; License:
@@ -137,31 +146,37 @@ It groups the objects in LIST according to the predicate
FN"
((not (string= "" j-help-remote-dictionary-url))
j-help-remote-dictionary-url))))
-(defun j-help-symbol-to-doc-url ( j-symbol )
- "Convert J-SYMBOL into localtion URL"
- (let ((alist-data (assoc j-symbol j-help-voc-alist))
- (dic (j-help-valid-dictionary)))
+(defun j-help-symbol-pair-to-doc-url ( alist-data )
+ ""
+ (let ((dic (j-help-valid-dictionary)))
(if (or (not alist-data) (string= dic ""))
(error "%s" "No dictionary found. Please specify a dictionary.")
(let ((name (car alist-data))
(doc-name (cdr alist-data)))
- (format "%s/%s.%s" dic doc-name "htm")))))
+ (format "%s/%s.%s" dic doc-name "htm")))))
+
+(defun j-help-symbol-to-doc-url ( j-symbol )
+ "Convert J-SYMBOL into localtion URL"
+ (j-help-symbol-pair-to-doc-url (assoc j-symbol j-help-voc-alist)))
(defun j-help-determine-symbol ( s point )
- "Internal function to determine j symbols. Should not be called directly"
- (let* ((l (length s)))
- (if (or (< point 0) (< l point)) '()
- (some
- (lambda (x)
- (let* ((check-size (car x)))
- (if (<= (+ check-size point) l)
- (when (string-match (cadr x) (substring s point (+ point
check-size)))
- (let* ((m (match-data))
- (ss (substring s (+ point (car m)) (+ point (cadr
m)))))
- (assoc ss (caddr x)))))))
- j-help-dictionary-data-block))))
+ "Internal function to determine j symbols. Should not be called directly
+
+string * int -> (string * string) list"
+ (unless (or (< point 0) (< (length s) point))
+ (some
+ (lambda (x)
+ (let* ((check-size (car x)))
+ (if (and
+ (<= (+ check-size point) (length s))
+ (string-match (cadr x) (substring s point (+ point check-size))))
+ (let* ((m (match-data))
+ (ss (substring s (+ point (car m)) (+ point (cadr m)))))
+ (assoc ss (caddr x))))))
+ j-help-dictionary-data-block)))
(defun j-help-determine-symbol-at-point ( point )
+ "int -> (string * string) list"
(save-excursion
(goto-char point)
(let* ((bol (point-at-bol))
@@ -169,8 +184,26 @@ It groups the objects in LIST according to the predicate
FN"
(s (buffer-substring-no-properties bol eol)))
(j-help-determine-symbol s (- point bol)))))
-;;(defun j-help-branch-determine-symbol-at-point ( point )
-;; )
+(defun j-help-branch-determine-symbol-at-point*
+ ( string current-index target-index resolved-symbol )
+ ""
+ (if (> current-index target-index) resolved-symbol
+ (let ((next-symbol (j-help-determine-symbol string current-index)))
+ (check-and-jump
+ string
+ (+ current-index (length (or (car next-symbol) " ")))
+ target-index
+ next-symbol))))
+
+(defun j-help-branch-determine-symbol-at-point ( point )
+ ""
+ (save-excursion
+ (goto-char point)
+ (j-help-branch-determine-symbol-at-point*
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))
+ (- (max (- point j-help-symbol-search-branch-limit) (point-at-bol))
(point-at-bol))
+ (- point (point-at-bol))
+ nil)))
;;;###autoload
(defun j-help-lookup-symbol ( symbol )
@@ -184,8 +217,12 @@ It groups the objects in LIST according to the predicate
FN"
(defun j-help-lookup-symbol-at-point ( point )
"Determine the symbol nearest to POINT and look it up in the dictionary"
(interactive "d")
- (if-let ((symbol (j-help-determine-symbol-at-point point)))
- (j-help-lookup-symbol symbol)
- (error "No symbol could be determined for point %d" point)))
+ (let ((symbol (j-help-branch-determine-symbol-at-point point)))
+ (if symbol
+ (j-help-lookup-symbol (car symbol))
+ (error "No symbol could be determined for point %d" point))))
+
(provide 'j-help)
+
+;;; j-help.el ends here
- [nongnu] elpa/j-mode c6865b5 07/56: Initial commit for help documentation look-up functionality., (continued)
- [nongnu] elpa/j-mode c6865b5 07/56: Initial commit for help documentation look-up functionality., ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 529cf67 06/56: Swaping progn with eval-when-compile in faces macro, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode d6fd35d 08/56: Updating README with information about the new faces added from j-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 41218f6 10/56: Doc-string updates, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 140c2b6 12/56: Updated README and cleaned up docs a bit, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 50b6ad1 13/56: Updating doc strings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode f4ede4b 18/56: Fixing unbalanced parenthesis, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 2e1ffe7 17/56: Merge branch 'modulate' of github.com:zellio/j-mode into modulate, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 0bf1acd 35/56: Fix "\\." (Suffix / Outfix) for `j-help-voc-alist', ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 0d2ba51 26/56: Adding warning about executable name clash with a Java package, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 3509c2d 15/56: Added branch search function for more intelligent symbol detection,
ELPA Syncer <=
- [nongnu] elpa/j-mode b470f04 19/56: Removing the -> macro, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 94a4d08 16/56: 1.0.0 Release, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode bd38533 36/56: Add "!." (Fit / Customize) to `j-help-voc-alist', ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode ff1a3f2 41/56: Merge pull request #10 from abo-abo/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode c61b17e 43/56: Mastering 1.1.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 060b900 40/56: Add "\\:" (Grade Down/Sort) to `j-font-lock-len-2-verbs', ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode b558903 44/56: j-help.el: Fix `lexical-binding' for Emacs24, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 4f7b75f 46/56: Merge remote-tracking branch 'lispnik/master', ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 36cb97e 31/56: Mastering v1.0.2, ELPA Syncer, 2021/08/29
- [nongnu] elpa/j-mode 11b02ca 48/56: Changed default jconsole to ijconsole since jconsole conflicts with some, ELPA Syncer, 2021/08/29