Skip to content

Commit 9e96a87

Browse files
author
arne
committed
fix company-capf error when point is on (
1 parent d8296a9 commit 9e96a87

File tree

1 file changed

+53
-52
lines changed

1 file changed

+53
-52
lines changed

el/sclang-language.el

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The expressions are joined as alternatives with the \\| operator."
6060
(defconst sclang-method-name-special-regexp
6161
(concat
6262
"[" (regexp-quote sclang-method-name-special-chars) "]+")
63-
"Regular expression matching method names composed of special characters.")
63+
"Regular expression matching method names composed of special characters.")
6464

6565
(defconst sclang-method-name-regexp
6666
(sclang-regexp-concat
@@ -102,10 +102,10 @@ A block is enclosed by parentheses where the opening parenthesis must
102102
be at the beginning of a line to avoid ambiguities.")
103103

104104
(defconst sclang-beginning-of-defun-regexp
105-
(sclang-regexp-concat
106-
sclang-class-definition-regexp
107-
sclang-block-regexp)
108-
"Regular expression matching the beginning of defuns.
105+
(sclang-regexp-concat
106+
sclang-class-definition-regexp
107+
sclang-block-regexp)
108+
"Regular expression matching the beginning of defuns.
109109
110110
The match is either the start of a class definition
111111
\(`sclang-class-definition-regexp') or the beginning of a code block
@@ -251,12 +251,12 @@ low-resource systems."
251251
(defun sclang-read-symbol (prompt &optional default predicate require-match inherit-input-method)
252252
(if sclang-use-symbol-table
253253
(cl-flet ((make-minibuffer-local-map
254-
(parent-keymap)
255-
(let ((map (make-sparse-keymap)))
256-
(set-keymap-parent map parent-keymap)
257-
;; override keys bound to valid symbols
258-
(define-key map [??] 'self-insert-command)
259-
map)))
254+
(parent-keymap)
255+
(let ((map (make-sparse-keymap)))
256+
(set-keymap-parent map parent-keymap)
257+
;; override keys bound to valid symbols
258+
(define-key map [??] 'self-insert-command)
259+
map)))
260260
(let ((symbol (sclang-get-symbol default))
261261
(minibuffer-local-completion-map (make-minibuffer-local-map
262262
minibuffer-local-completion-map))
@@ -457,9 +457,10 @@ are considered."
457457
"Function used for `completion-at-point-functions' in `sclang-mode'."
458458
(let* ((end (point))
459459
(beg (save-excursion
460-
(backward-sexp 1)
461-
(skip-syntax-forward "'")
462-
(point)))
460+
(or (ignore-errors (backward-sexp 1)
461+
(skip-syntax-forward "'")
462+
(point))
463+
(point))))
463464
(pattern (buffer-substring-no-properties beg end))
464465
(case-fold-search nil)
465466
(predicate (if (sclang-class-name-p pattern)
@@ -770,45 +771,45 @@ Looks for all repetitive patterns in ITEMS recursively. Therefore, it is
770771
computationally expensive, especially when ITEMS is a long list. If you don't
771772
want smart pattern guessing, use `sclang-format' directly to format your Pseq."
772773
(cl-labels ((find-reps (items)
773-
(let (r)
774-
(while items
775-
(let ((ret (car items))
776-
(skip 1)
777-
(rep (length items)))
778-
(catch 'match-found
779-
(while (>= rep 2)
780-
(let ((i (/ (length items) rep)))
781-
(while (> i 0)
782-
(let ((sublst (cl-subseq items 0 i)))
783-
(when (catch 'equal
784-
(let ((a items))
785-
(cl-loop repeat rep do
786-
(let ((b sublst))
787-
(while b
788-
(unless (eql (car b) (car a))
789-
(throw 'equal nil))
790-
(setq a (cdr a)
791-
b (cdr b)))))
792-
t))
793-
(setq ret (cons rep (if (> i 5)
794-
(find-reps sublst)
795-
sublst))
796-
skip (* i rep))
797-
(throw 'match-found t))
798-
(cl-decf i))))
799-
(cl-decf rep)))
800-
(accept-process-output nil 0 100)
801-
(message "Processed...%S" ret) ;; invent better progress info
802-
(setq r (append r (list ret))
803-
items (nthcdr skip items))))
804-
r))
774+
(let (r)
775+
(while items
776+
(let ((ret (car items))
777+
(skip 1)
778+
(rep (length items)))
779+
(catch 'match-found
780+
(while (>= rep 2)
781+
(let ((i (/ (length items) rep)))
782+
(while (> i 0)
783+
(let ((sublst (cl-subseq items 0 i)))
784+
(when (catch 'equal
785+
(let ((a items))
786+
(cl-loop repeat rep do
787+
(let ((b sublst))
788+
(while b
789+
(unless (eql (car b) (car a))
790+
(throw 'equal nil))
791+
(setq a (cdr a)
792+
b (cdr b)))))
793+
t))
794+
(setq ret (cons rep (if (> i 5)
795+
(find-reps sublst)
796+
sublst))
797+
skip (* i rep))
798+
(throw 'match-found t))
799+
(cl-decf i))))
800+
(cl-decf rep)))
801+
(accept-process-output nil 0 100)
802+
(message "Processed...%S" ret) ;; invent better progress info
803+
(setq r (append r (list ret))
804+
items (nthcdr skip items))))
805+
r))
805806
(elem-to-string (elem)
806-
(cond
807-
((consp elem)
808-
(concat "Pseq([ "
809-
(mapconcat #'elem-to-string (cdr elem) ", ")
810-
(format " ], %d)" (car elem))))
811-
(t (sclang-object-to-string elem)))))
807+
(cond
808+
((consp elem)
809+
(concat "Pseq([ "
810+
(mapconcat #'elem-to-string (cdr elem) ", ")
811+
(format " ], %d)" (car elem))))
812+
(t (sclang-object-to-string elem)))))
812813
(let ((compressed (find-reps items)))
813814
(if (and (= (length compressed) 1) (consp (car compressed)))
814815
(elem-to-string (car compressed))

0 commit comments

Comments
 (0)