]> code.delx.au - gnu-emacs-elpa/commitdiff
Squashed 'packages/company-math/' changes from b585117..2e24a08
authorVitalie Spinu <spinuvit@gmail.com>
Sun, 28 Feb 2016 14:56:45 +0000 (15:56 +0100)
committerVitalie Spinu <spinuvit@gmail.com>
Sun, 28 Feb 2016 14:56:45 +0000 (15:56 +0100)
2e24a08 Version 1.1
8e64cae Untabify and add .dir-locals
ce46d91 Merge pull request #7 from cpitclaudel/always-offer-completions
3c906cd Always offer completions (workaround for company issue #476)
21ac1c7 Update readme as per TeX-mode-hook problem
d0db15e [Fix #6] Add `tex-math` to `company-math-allow-latex-symbols-in-faces`
f5cedcf Use generic `tex-mode-hook` in readme

git-subtree-dir: packages/company-math
git-subtree-split: 2e24a088d660d0bf37585a664eddbbb6c4a8e20d

.dir-locals.el [new file with mode: 0644]
company-math.el
readme.md

diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644 (file)
index 0000000..064a938
--- /dev/null
@@ -0,0 +1,3 @@
+
+((emacs-lisp-mode
+  (indent-tabs-mode)))
index 7d8efabf153341c0735a6703b2854a4ab1ff3211..383b4de5df63f5dc917780ea1752218c4d8ab7fd 100644 (file)
@@ -4,7 +4,7 @@
 ;; Author: Vitalie Spinu
 ;; URL: https://github.com/vspinu/company-math
 ;; Keywords:  Unicode, symbols, completion
-;; Version: 1.0.1
+;; Version: 1.1
 ;; Package-Requires: ((company "0.8.0") (math-symbol-lists "1.0"))
 ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -52,15 +52,15 @@ When set to special value t, allow on all faces except those in
 `company-math-disallow-unicode-symbols-in-faces'."
   :group 'company-math
   :type '(choice (const t)
-                (repeat :tag "Faces" symbol)))
+                 (repeat :tag "Faces" symbol)))
 
-(defcustom company-math-allow-latex-symbols-in-faces '(font-latex-math-face)
+(defcustom company-math-allow-latex-symbols-in-faces '(tex-math font-latex-math-face)
   "List of faces to disallow the insertion of latex mathematical symbols.
 When set to special value t, allow on all faces except those in
 `company-math-disallow-latex-symbols-in-faces'."
   :group 'company-math
   :type '(choice (const t)
-                (repeat :tag "Faces" symbol)))
+                 (repeat :tag "Faces" symbol)))
 
 (defcustom company-math-disallow-unicode-symbols-in-faces '(font-latex-math-face)
   "List of faces to disallow the insertion of Unicode symbols."
@@ -83,10 +83,10 @@ corresponding unicode symbol."
   (delq nil
         (mapcar
          #'(lambda (el)
-            (let* ((tex (substring (nth 1 el) 1))
-                   (ch (and (nth 2 el) (decode-char 'ucs (nth 2 el))))
-                   (symb (and ch (char-to-string ch))))
-              (propertize tex :symbol symb)))
+             (let* ((tex (substring (nth 1 el) 1))
+                    (ch (and (nth 2 el) (decode-char 'ucs (nth 2 el))))
+                    (symb (and ch (char-to-string ch))))
+               (propertize tex :symbol symb)))
          alist)))
 
 (defconst company-math--symbols
@@ -97,19 +97,19 @@ corresponding unicode symbol."
 
 (defun company-math--prefix (allow-faces disallow-faces)
   (let* ((face (get-text-property (point) 'face))
-        (face (or (car-safe face) face))
-        (insertp (and (not (memq face disallow-faces))
-                      (or (eq t allow-faces)
-                          (memq face allow-faces)))))
+         (face (or (car-safe face) face))
+         (insertp (and (not (memq face disallow-faces))
+                       (or (eq t allow-faces)
+                           (memq face allow-faces)))))
     (when insertp
       (save-excursion
-       (when (looking-back company-math-prefix-regexp (point-at-bol))
-         (match-string 1))))))
+        (when (looking-back company-math-prefix-regexp (point-at-bol))
+          (match-string 1))))))
 
 (defun company-math--substitute-unicode (symbol)
   "Substitute preceding latex command with with SYMBOL."
   (let ((pos (point))
-       (inhibit-point-motion-hooks t))
+        (inhibit-point-motion-hooks t))
     (when (re-search-backward company-math-prefix-regexp)
       (delete-region (match-beginning 0) pos)
       (insert symbol))))
@@ -124,7 +124,7 @@ corresponding unicode symbol."
   (cl-case command
     (interactive (company-begin-backend 'company-latex-commands))
     (prefix (unless (company-in-string-or-comment)
-             (company-math--prefix t '())))
+              (company-math--prefix t '())))
     (candidates (all-completions arg math-symbol-list-latex-commands))
     (sorted t)))
 
@@ -135,25 +135,33 @@ corresponding unicode symbol."
   (cl-case command
     (interactive (company-begin-backend 'company-math-symbols-latex))
     (prefix (unless (company-in-string-or-comment)
-             (company-math--prefix company-math-allow-latex-symbols-in-faces
-                                   company-math-disallow-latex-symbols-in-faces)))
+              (company-math--prefix company-math-allow-latex-symbols-in-faces
+                                    company-math-disallow-latex-symbols-in-faces)))
     (annotation (concat " " (get-text-property 0 :symbol arg)))
     (candidates (all-completions arg company-math--symbols))))
 
 ;;;###autoload
 (defun company-math-symbols-unicode (command &optional arg &rest ignored)
-  "Company backend for LaTeX mathematical symbols."
+  "Company backend for insertion of Unicode mathematical symbols.
+See the unicode-math page [1] for a list of fonts that have a
+good support for mathematical symbols.
+
+ [1] http://ftp.snt.utwente.nl/pub/software/tex/help/Catalogue/entries/unicode-math.html
+"
   (interactive (list 'interactive))
   (cl-case command
     (interactive (company-begin-backend 'company-math-symbols-unicode))
     (prefix (company-math--prefix company-math-allow-unicode-symbols-in-faces
-                                 company-math-disallow-unicode-symbols-in-faces))
+                                  company-math-disallow-unicode-symbols-in-faces))
     (annotation (concat " " (get-text-property 0 :symbol arg)))
-    (candidates (all-completions arg company-math--symbols))
+    ;; Space added to ensure that completions are never typed in full.
+    ;; See https://github.com/company-mode/company-mode/issues/476
+    (candidates (mapcar (lambda (candidate)
+                          (concat candidate " "))
+                        (all-completions arg company-math--symbols)))
     (post-completion (company-math--substitute-unicode
-                     (get-text-property 0 :symbol arg)))))
+                      (get-text-property 0 :symbol arg)))))
 
 
 (provide 'company-math)
-
 ;;; company-math.el ends here
index cc471942ea27f6a807f7c7b7e55068ecc8aaacb3..fa8025837520f492787ccdf984f1b5f3e8901505 100644 (file)
--- a/readme.md
+++ b/readme.md
@@ -39,13 +39,19 @@ or locally per emacs mode:
 ;; local configuration for TeX modes
 (defun my-latex-mode-setup ()
   (setq-local company-backends
-              (append '(company-math-symbols-latex company-latex-commands)
+              (append '((company-math-symbols-latex company-latex-commands))
                       company-backends)))
 
-(add-hook 'TeX-mode-hook 'my-latex-mode-setup)
+(add-hook 'tex-mode-hook 'my-latex-mode-setup)
  
 ```
 
+If you are using `AUCTeX` you might need to use `TeX-mode-hook` instead:
+
+```
+(add-hook TeX-mode-hook 'my-latex-mode-setup)
+```
+
 ## Customization ##
 
 Set `company-tooltip-align-annotations` to t in order to allin symbols to the