]> code.delx.au - gnu-emacs-elpa/blobdiff - company-cmake.el
Move company-files closer to the front of company-backends
[gnu-emacs-elpa] / company-cmake.el
index b38ece00aa8631bdbe66af01af1b6d8341a7a2fe..010df32e43d25f4193bd66e12a6b11473a29895e 100644 (file)
@@ -1,4 +1,4 @@
-;;; company-cmake.el --- company-mode completion back-end for CMake
+;;; company-cmake.el --- company-mode completion backend for CMake
 
 ;; Copyright (C) 2013-2014  Free Software Foundation, Inc.
 
@@ -29,7 +29,7 @@
 (require 'cl-lib)
 
 (defgroup company-cmake nil
-  "Completion back-end for CMake."
+  "Completion backend for CMake."
   :group 'company)
 
 (defcustom company-cmake-executable
@@ -59,9 +59,14 @@ They affect which types of symbols we get completion candidates for.")
 
 (defun company-cmake--replace-tags (rlt)
   (setq rlt (replace-regexp-in-string
-             "\\(.*\\)<LANG>\\(.*\\)"
-             (mapconcat 'identity '("\\1CXX\\2" "\\1C\\2" "\\1G77\\2") "\n")
-             rlt))
+             "\\(.*?\\(IS_GNU\\)?\\)<LANG>\\(.*\\)"
+             (lambda (_match)
+               (mapconcat 'identity
+                          (if (match-beginning 2)
+                              '("\\1CXX\\3" "\\1C\\3" "\\1G77\\3")
+                            '("\\1CXX\\3" "\\1C\\3" "\\1Fortran\\3"))
+                          "\n"))
+             rlt t))
   (setq rlt (replace-regexp-in-string
              "\\(.*\\)<CONFIG>\\(.*\\)"
              (mapconcat 'identity '("\\1DEBUG\\2" "\\1RELEASE\\2"
@@ -123,7 +128,7 @@ They affect which types of symbols we get completion candidates for.")
 
 (defun company-cmake--unexpand-candidate (candidate)
   (cond
-   ((string-match "^CMAKE_\\(C\\|CXX\\|G77\\)\\(_.*\\)$" candidate)
+   ((string-match "^CMAKE_\\(C\\|CXX\\|Fortran\\)\\(_.*\\)$" candidate)
     (setq candidate (concat "CMAKE_<LANG>" (match-string 2 candidate))))
 
    ;; C flags
@@ -131,7 +136,7 @@ They affect which types of symbols we get completion candidates for.")
     (setq candidate (concat (match-string 1 candidate) "IS_GNU<LANG>")))
 
    ;; C flags
-   ((string-match "^\\(.*_\\)OVERRIDE_\\(C\\|CXX\\|G77\\)$" candidate)
+   ((string-match "^\\(.*_\\)OVERRIDE_\\(C\\|CXX\\|Fortran\\)$" candidate)
     (setq candidate (concat (match-string 1 candidate) "OVERRIDE_<LANG>")))
 
    ((string-match "^\\(.*\\)\\(_DEBUG\\|_RELEASE\\|_RELWITHDEBINFO\\|_MINSIZEREL\\)\\(.*\\)$" candidate)
@@ -173,7 +178,7 @@ They affect which types of symbols we get completion candidates for.")
                                        (point-max))))))
 
 (defun company-cmake (command &optional arg &rest ignored)
-  "`company-mode' completion back-end for CMake.
+  "`company-mode' completion backend for CMake.
 CMake is a cross-platform, open-source make system."
   (interactive (list 'interactive))
   (cl-case command