| @ -1,80 +0,0 @@ | |||||
| ;;; async-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil "async" "async.el" (21570 22530 0 0)) | |||||
| ;;; Generated autoloads from async.el | |||||
| (autoload 'async-start-process "async" "\ | |||||
| Start the executable PROGRAM asynchronously. See `async-start'. | |||||
| PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the | |||||
| process object when done. If FINISH-FUNC is nil, the future | |||||
| object will return the process object when the program is | |||||
| finished. | |||||
| \(fn NAME PROGRAM FINISH-FUNC &rest PROGRAM-ARGS)" nil nil) | |||||
| (autoload 'async-start "async" "\ | |||||
| Execute START-FUNC (often a lambda) in a subordinate Emacs process. | |||||
| When done, the return value is passed to FINISH-FUNC. Example: | |||||
| (async-start | |||||
| ;; What to do in the child process | |||||
| (lambda () | |||||
| (message \"This is a test\") | |||||
| (sleep-for 3) | |||||
| 222) | |||||
| ;; What to do when it finishes | |||||
| (lambda (result) | |||||
| (message \"Async process done, result should be 222: %s\" | |||||
| result))) | |||||
| If FINISH-FUNC is nil or missing, a future is returned that can | |||||
| be inspected using `async-get', blocking until the value is | |||||
| ready. Example: | |||||
| (let ((proc (async-start | |||||
| ;; What to do in the child process | |||||
| (lambda () | |||||
| (message \"This is a test\") | |||||
| (sleep-for 3) | |||||
| 222)))) | |||||
| (message \"I'm going to do some work here\") ;; .... | |||||
| (message \"Waiting on async process, result should be 222: %s\" | |||||
| (async-get proc))) | |||||
| If you don't want to use a callback, and you don't care about any | |||||
| return value form the child process, pass the `ignore' symbol as | |||||
| the second argument (if you don't, and never call `async-get', it | |||||
| will leave *emacs* process buffers hanging around): | |||||
| (async-start | |||||
| (lambda () | |||||
| (delete-file \"a remote file on a slow link\" nil)) | |||||
| 'ignore) | |||||
| Note: Even when FINISH-FUNC is present, a future is still | |||||
| returned except that it yields no value (since the value is | |||||
| passed to FINISH-FUNC). Call `async-get' on such a future always | |||||
| returns nil. It can still be useful, however, as an argument to | |||||
| `async-ready' or `async-wait'. | |||||
| \(fn START-FUNC &optional FINISH-FUNC)" nil t) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil nil ("async-bytecomp.el" "async-pkg.el" "dired-async.el" | |||||
| ;;;;;; "smtpmail-async.el") (21570 22530 118194 0)) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; async-autoloads.el ends here | |||||
| @ -1,107 +0,0 @@ | |||||
| ;;; async-bytecomp.el --- Async functions to compile elisp files async | |||||
| ;; Copyright (C) 2014 John Wiegley | |||||
| ;; Copyright (C) 2014 Thierry Volpiatto | |||||
| ;; Authors: John Wiegley <jwiegley@gmail.com> | |||||
| ;; Thierry Volpiatto <thierry.volpiatto@gmail.com> | |||||
| ;; Keywords: dired async byte-compile | |||||
| ;; X-URL: https://github.com/jwiegley/dired-async | |||||
| ;; This program is free software; you can redistribute it and/or | |||||
| ;; modify it under the terms of the GNU General Public License as | |||||
| ;; published by the Free Software Foundation; either version 2, or (at | |||||
| ;; your option) any later version. | |||||
| ;; This program is distributed in the hope that it will be useful, but | |||||
| ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| ;; General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs; see the file COPYING. If not, write to the | |||||
| ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |||||
| ;; Boston, MA 02111-1307, USA. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;; This package provide the `async-byte-recompile-directory' function | |||||
| ;; which allows, as the name says to recompile a directory outside of | |||||
| ;; your running emacs. | |||||
| ;; The benefit is your files will be compiled in a clean environment without | |||||
| ;; the old *.el files loaded. | |||||
| ;; Among other things, this fix a bug in package.el which recompile | |||||
| ;; the new files in the current environment with the old files loaded, creating | |||||
| ;; errors in most packages after upgrades. | |||||
| ;; | |||||
| ;; NB: This package is advicing the function `package--compile'. | |||||
| ;;; Code: | |||||
| (require 'cl-lib) | |||||
| (require 'async) | |||||
| (defvar async-byte-compile-log-file "~/.emacs.d/async-bytecomp.log") | |||||
| (defun async-byte-recompile-directory (directory &optional arg force quiet) | |||||
| (cl-loop with dir = (directory-files directory t "\\.elc\\'") | |||||
| unless dir return nil | |||||
| for f in dir | |||||
| when (file-exists-p f) do (delete-file f)) | |||||
| ;; Ensure async is reloaded when async.elc is deleted. | |||||
| ;; This happen when recompiling its own directory. | |||||
| (load "async") | |||||
| (let ((call-back | |||||
| `(lambda (&optional ignore) | |||||
| (if (file-exists-p async-byte-compile-log-file) | |||||
| (let ((buf (get-buffer-create byte-compile-log-buffer)) | |||||
| (n 0)) | |||||
| (with-current-buffer buf | |||||
| (goto-char (point-max)) | |||||
| (let ((inhibit-read-only t)) | |||||
| (insert-file-contents async-byte-compile-log-file) | |||||
| (compilation-mode)) | |||||
| (display-buffer buf) | |||||
| (delete-file async-byte-compile-log-file) | |||||
| (unless ,quiet | |||||
| (save-excursion | |||||
| (goto-char (point-min)) | |||||
| (while (re-search-forward "^.*:Error:" nil t) | |||||
| (incf n))) | |||||
| (if (> n 0) | |||||
| (message "Failed to compile %d files in directory `%s'" n ,directory) | |||||
| (message "Directory `%s' compiled asynchronously with warnings" ,directory))))) | |||||
| (unless ,quiet | |||||
| (message "Directory `%s' compiled asynchronously with success" ,directory)))))) | |||||
| (async-start | |||||
| `(lambda () | |||||
| (require 'bytecomp) | |||||
| ,(async-inject-variables "\\`load-path\\'") | |||||
| (let ((default-directory (file-name-as-directory ,directory)) | |||||
| error-data) | |||||
| (add-to-list 'load-path default-directory) | |||||
| (byte-recompile-directory ,directory ,arg ,force) | |||||
| (when (get-buffer byte-compile-log-buffer) | |||||
| (setq error-data (with-current-buffer byte-compile-log-buffer | |||||
| (buffer-substring-no-properties (point-min) (point-max)))) | |||||
| (unless (string= error-data "") | |||||
| (with-temp-file ,async-byte-compile-log-file | |||||
| (erase-buffer) | |||||
| (insert error-data)))))) | |||||
| call-back) | |||||
| (message "Started compiling asynchronously directory %s..." directory))) | |||||
| (defadvice package--compile (around byte-compile-async activate) | |||||
| ;; FIXME this seems redundant and unneeded, the only thing it | |||||
| ;; does is loading the autoload file to update load-path but | |||||
| ;; async-byte-recompile-directory is already doing this. | |||||
| ;; for the rest (i.e installing info) it is done anyway after | |||||
| ;; compilation in package-activate (force arg). | |||||
| (package-activate-1 pkg-desc) | |||||
| (load "async-bytecomp") | |||||
| (async-byte-recompile-directory (package-desc-dir pkg-desc) 0 t t)) | |||||
| (provide 'async-bytecomp) | |||||
| ;;; async-bytecomp.el ends here | |||||
| @ -1,4 +0,0 @@ | |||||
| (define-package "async" "20141001.151" "Asynchronous processing in Emacs" 'nil) | |||||
| ;; Local Variables: | |||||
| ;; no-byte-compile: t | |||||
| ;; End: | |||||
| @ -1,291 +0,0 @@ | |||||
| ;;; async --- Asynchronous processing in Emacs | |||||
| ;; Copyright (C) 2012~2014 John Wiegley | |||||
| ;; Author: John Wiegley <jwiegley@gmail.com> | |||||
| ;; Created: 18 Jun 2012 | |||||
| ;; Keywords: async | |||||
| ;; X-URL: https://github.com/jwiegley/emacs-async | |||||
| ;; This program is free software; you can redistribute it and/or | |||||
| ;; modify it under the terms of the GNU General Public License as | |||||
| ;; published by the Free Software Foundation; either version 2, or (at | |||||
| ;; your option) any later version. | |||||
| ;; This program is distributed in the hope that it will be useful, but | |||||
| ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| ;; General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs; see the file COPYING. If not, write to the | |||||
| ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |||||
| ;; Boston, MA 02111-1307, USA. | |||||
| ;;; Commentary: | |||||
| ;; Adds the ability to call asynchronous functions and process with ease. See | |||||
| ;; the documentation for `async-start' and `async-start-process'. | |||||
| ;;; Code: | |||||
| (defgroup async nil | |||||
| "Simple asynchronous processing in Emacs" | |||||
| :group 'emacs) | |||||
| (defvar async-debug nil) | |||||
| (defvar async-send-over-pipe t) | |||||
| (defvar async-in-child-emacs nil) | |||||
| (defvar async-callback nil) | |||||
| (defvar async-callback-for-process nil) | |||||
| (defvar async-callback-value nil) | |||||
| (defvar async-callback-value-set nil) | |||||
| (defvar async-current-process nil) | |||||
| (defun async-inject-variables | |||||
| (include-regexp &optional predicate exclude-regexp) | |||||
| "Return a `setq' form that replicates part of the calling environment. | |||||
| It sets the value for every variable matching INCLUDE-REGEXP and | |||||
| also PREDICATE. It will not perform injection for any variable | |||||
| matching EXCLUDE-REGEXP (if present). It is intended to be used | |||||
| as follows: | |||||
| (async-start | |||||
| `(lambda () | |||||
| (require 'smtpmail) | |||||
| (with-temp-buffer | |||||
| (insert ,(buffer-substring-no-properties (point-min) (point-max))) | |||||
| ;; Pass in the variable environment for smtpmail | |||||
| ,(async-inject-variables \"\\`\\(smtpmail\\|\\(user-\\)?mail\\)-\") | |||||
| (smtpmail-send-it))) | |||||
| 'ignore)" | |||||
| `(setq | |||||
| ,@(let (bindings) | |||||
| (mapatoms | |||||
| (lambda (sym) | |||||
| (if (and (boundp sym) | |||||
| (or (null include-regexp) | |||||
| (string-match include-regexp (symbol-name sym))) | |||||
| (not (string-match | |||||
| (or exclude-regexp "-syntax-table\\'") | |||||
| (symbol-name sym)))) | |||||
| (let ((value (symbol-value sym))) | |||||
| (when (or (null predicate) | |||||
| (funcall predicate sym)) | |||||
| (setq bindings (cons `(quote ,value) bindings) | |||||
| bindings (cons sym bindings))))))) | |||||
| bindings))) | |||||
| (defalias 'async-inject-environment 'async-inject-variables) | |||||
| (defun async-handle-result (func result buf) | |||||
| (if (null func) | |||||
| (progn | |||||
| (set (make-local-variable 'async-callback-value) result) | |||||
| (set (make-local-variable 'async-callback-value-set) t)) | |||||
| (unwind-protect | |||||
| (if (and (listp result) | |||||
| (eq 'async-signal (nth 0 result))) | |||||
| (signal (car (nth 1 result)) | |||||
| (cdr (nth 1 result))) | |||||
| (funcall func result)) | |||||
| (unless async-debug | |||||
| (kill-buffer buf))))) | |||||
| (defun async-when-done (proc &optional change) | |||||
| "Process sentinal used to retrieve the value from the child process." | |||||
| (when (eq 'exit (process-status proc)) | |||||
| (with-current-buffer (process-buffer proc) | |||||
| (let ((async-current-process proc)) | |||||
| (if (= 0 (process-exit-status proc)) | |||||
| (if async-callback-for-process | |||||
| (if async-callback | |||||
| (prog1 | |||||
| (funcall async-callback proc) | |||||
| (unless async-debug | |||||
| (kill-buffer (current-buffer)))) | |||||
| (set (make-local-variable 'async-callback-value) proc) | |||||
| (set (make-local-variable 'async-callback-value-set) t)) | |||||
| (goto-char (point-max)) | |||||
| (backward-sexp) | |||||
| (async-handle-result async-callback (read (current-buffer)) | |||||
| (current-buffer))) | |||||
| (set (make-local-variable 'async-callback-value) | |||||
| (list 'error | |||||
| (format "Async process '%s' failed with exit code %d" | |||||
| (process-name proc) (process-exit-status proc)))) | |||||
| (set (make-local-variable 'async-callback-value-set) t)))))) | |||||
| (defun async--receive-sexp (&optional stream) | |||||
| (let ((sexp (decode-coding-string (base64-decode-string | |||||
| (read stream)) 'utf-8-unix))) | |||||
| (if async-debug | |||||
| (message "Received sexp {{{%s}}}" (pp-to-string sexp))) | |||||
| (setq sexp (read sexp)) | |||||
| (if async-debug | |||||
| (message "Read sexp {{{%s}}}" (pp-to-string sexp))) | |||||
| (eval sexp))) | |||||
| (defun async--insert-sexp (sexp) | |||||
| (prin1 sexp (current-buffer)) | |||||
| ;; Just in case the string we're sending might contain EOF | |||||
| (encode-coding-region (point-min) (point-max) 'utf-8-unix) | |||||
| (base64-encode-region (point-min) (point-max) t) | |||||
| (goto-char (point-min)) (insert ?\") | |||||
| (goto-char (point-max)) (insert ?\" ?\n)) | |||||
| (defun async--transmit-sexp (process sexp) | |||||
| (with-temp-buffer | |||||
| (if async-debug | |||||
| (message "Transmitting sexp {{{%s}}}" (pp-to-string sexp))) | |||||
| (async--insert-sexp sexp) | |||||
| (process-send-region process (point-min) (point-max)))) | |||||
| (defun async-batch-invoke () | |||||
| "Called from the child Emacs process' command-line." | |||||
| (setq async-in-child-emacs t | |||||
| debug-on-error async-debug) | |||||
| (if debug-on-error | |||||
| (prin1 (funcall | |||||
| (async--receive-sexp (unless async-send-over-pipe | |||||
| command-line-args-left)))) | |||||
| (condition-case err | |||||
| (prin1 (funcall | |||||
| (async--receive-sexp (unless async-send-over-pipe | |||||
| command-line-args-left)))) | |||||
| (error | |||||
| (prin1 (list 'async-signal err)))))) | |||||
| (defun async-ready (future) | |||||
| "Query a FUTURE to see if the ready is ready -- i.e., if no blocking | |||||
| would result from a call to `async-get' on that FUTURE." | |||||
| (and (memq (process-status future) '(exit signal)) | |||||
| (with-current-buffer (process-buffer future) | |||||
| async-callback-value-set))) | |||||
| (defun async-wait (future) | |||||
| "Wait for FUTURE to become ready." | |||||
| (while (not (async-ready future)) | |||||
| (sit-for 0.05))) | |||||
| (defun async-get (future) | |||||
| "Get the value from an asynchronously function when it is ready. | |||||
| FUTURE is returned by `async-start' or `async-start-process' when | |||||
| its FINISH-FUNC is nil." | |||||
| (async-wait future) | |||||
| (with-current-buffer (process-buffer future) | |||||
| (async-handle-result #'identity async-callback-value (current-buffer)))) | |||||
| (defun async-message-p (value) | |||||
| "Return true of VALUE is an async.el message packet." | |||||
| (and (listp value) | |||||
| (plist-get value :async-message))) | |||||
| (defun async-send (&rest args) | |||||
| "Send the given messages to the asychronous Emacs PROCESS." | |||||
| (let ((args (append args '(:async-message t)))) | |||||
| (if async-in-child-emacs | |||||
| (if async-callback | |||||
| (funcall async-callback args)) | |||||
| (async--transmit-sexp (car args) (list 'quote (cdr args)))))) | |||||
| (defun async-receive (&rest args) | |||||
| "Send the given messages to the asychronous Emacs PROCESS." | |||||
| (async--receive-sexp)) | |||||
| ;;;###autoload | |||||
| (defun async-start-process (name program finish-func &rest program-args) | |||||
| "Start the executable PROGRAM asynchronously. See `async-start'. | |||||
| PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the | |||||
| process object when done. If FINISH-FUNC is nil, the future | |||||
| object will return the process object when the program is | |||||
| finished." | |||||
| (let* ((buf (generate-new-buffer (concat "*" name "*"))) | |||||
| (proc (let ((process-connection-type nil)) | |||||
| (apply #'start-process name buf program program-args)))) | |||||
| (with-current-buffer buf | |||||
| (set (make-local-variable 'async-callback) finish-func) | |||||
| (set-process-sentinel proc #'async-when-done) | |||||
| (unless (string= name "emacs") | |||||
| (set (make-local-variable 'async-callback-for-process) t)) | |||||
| proc))) | |||||
| ;;;###autoload | |||||
| (defmacro async-start (start-func &optional finish-func) | |||||
| "Execute START-FUNC (often a lambda) in a subordinate Emacs process. | |||||
| When done, the return value is passed to FINISH-FUNC. Example: | |||||
| (async-start | |||||
| ;; What to do in the child process | |||||
| (lambda () | |||||
| (message \"This is a test\") | |||||
| (sleep-for 3) | |||||
| 222) | |||||
| ;; What to do when it finishes | |||||
| (lambda (result) | |||||
| (message \"Async process done, result should be 222: %s\" | |||||
| result))) | |||||
| If FINISH-FUNC is nil or missing, a future is returned that can | |||||
| be inspected using `async-get', blocking until the value is | |||||
| ready. Example: | |||||
| (let ((proc (async-start | |||||
| ;; What to do in the child process | |||||
| (lambda () | |||||
| (message \"This is a test\") | |||||
| (sleep-for 3) | |||||
| 222)))) | |||||
| (message \"I'm going to do some work here\") ;; .... | |||||
| (message \"Waiting on async process, result should be 222: %s\" | |||||
| (async-get proc))) | |||||
| If you don't want to use a callback, and you don't care about any | |||||
| return value form the child process, pass the `ignore' symbol as | |||||
| the second argument (if you don't, and never call `async-get', it | |||||
| will leave *emacs* process buffers hanging around): | |||||
| (async-start | |||||
| (lambda () | |||||
| (delete-file \"a remote file on a slow link\" nil)) | |||||
| 'ignore) | |||||
| Note: Even when FINISH-FUNC is present, a future is still | |||||
| returned except that it yields no value (since the value is | |||||
| passed to FINISH-FUNC). Call `async-get' on such a future always | |||||
| returns nil. It can still be useful, however, as an argument to | |||||
| `async-ready' or `async-wait'." | |||||
| (require 'find-func) | |||||
| (let ((procvar (make-symbol "proc"))) | |||||
| `(let* ((sexp ,start-func) | |||||
| (,procvar | |||||
| (async-start-process | |||||
| "emacs" (file-truename | |||||
| (expand-file-name invocation-name | |||||
| invocation-directory)) | |||||
| ,finish-func | |||||
| "-Q" "-l" | |||||
| ;; Using `locate-library' ensure we use the right file | |||||
| ;; when the .elc have been deleted. | |||||
| ,(locate-library "async") | |||||
| "-batch" "-f" "async-batch-invoke" | |||||
| (if async-send-over-pipe | |||||
| "<none>" | |||||
| (with-temp-buffer | |||||
| (async--insert-sexp (list 'quote sexp)) | |||||
| (buffer-string)))))) | |||||
| (if async-send-over-pipe | |||||
| (async--transmit-sexp ,procvar (list 'quote sexp))) | |||||
| ,procvar))) | |||||
| (defmacro async-sandbox(func) | |||||
| "Evaluate FUNC in a separate Emacs process, synchronously." | |||||
| `(async-get (async-start ,func))) | |||||
| (provide 'async) | |||||
| ;;; async.el ends here | |||||
| @ -0,0 +1,81 @@ | |||||
| ;;; async-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil "async" "async.el" (21837 24217 0 0)) | |||||
| ;;; Generated autoloads from async.el | |||||
| (autoload 'async-start-process "async" "\ | |||||
| Start the executable PROGRAM asynchronously. See `async-start'. | |||||
| PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the | |||||
| process object when done. If FINISH-FUNC is nil, the future | |||||
| object will return the process object when the program is | |||||
| finished. Set DEFAULT-DIRECTORY to change PROGRAM's current | |||||
| working directory. | |||||
| \(fn NAME PROGRAM FINISH-FUNC &rest PROGRAM-ARGS)" nil nil) | |||||
| (autoload 'async-start "async" "\ | |||||
| Execute START-FUNC (often a lambda) in a subordinate Emacs process. | |||||
| When done, the return value is passed to FINISH-FUNC. Example: | |||||
| (async-start | |||||
| ;; What to do in the child process | |||||
| (lambda () | |||||
| (message \"This is a test\") | |||||
| (sleep-for 3) | |||||
| 222) | |||||
| ;; What to do when it finishes | |||||
| (lambda (result) | |||||
| (message \"Async process done, result should be 222: %s\" | |||||
| result))) | |||||
| If FINISH-FUNC is nil or missing, a future is returned that can | |||||
| be inspected using `async-get', blocking until the value is | |||||
| ready. Example: | |||||
| (let ((proc (async-start | |||||
| ;; What to do in the child process | |||||
| (lambda () | |||||
| (message \"This is a test\") | |||||
| (sleep-for 3) | |||||
| 222)))) | |||||
| (message \"I'm going to do some work here\") ;; .... | |||||
| (message \"Waiting on async process, result should be 222: %s\" | |||||
| (async-get proc))) | |||||
| If you don't want to use a callback, and you don't care about any | |||||
| return value form the child process, pass the `ignore' symbol as | |||||
| the second argument (if you don't, and never call `async-get', it | |||||
| will leave *emacs* process buffers hanging around): | |||||
| (async-start | |||||
| (lambda () | |||||
| (delete-file \"a remote file on a slow link\" nil)) | |||||
| 'ignore) | |||||
| Note: Even when FINISH-FUNC is present, a future is still | |||||
| returned except that it yields no value (since the value is | |||||
| passed to FINISH-FUNC). Call `async-get' on such a future always | |||||
| returns nil. It can still be useful, however, as an argument to | |||||
| `async-ready' or `async-wait'. | |||||
| \(fn START-FUNC &optional FINISH-FUNC)" nil t) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil nil ("async-bytecomp.el" "async-pkg.el" "dired-async.el" | |||||
| ;;;;;; "smtpmail-async.el") (21837 24217 654301 0)) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; async-autoloads.el ends here | |||||
| @ -0,0 +1,149 @@ | |||||
| ;;; async-bytecomp.el --- Async functions to compile elisp files async | |||||
| ;; Copyright (C) 2014 John Wiegley | |||||
| ;; Copyright (C) 2014 Thierry Volpiatto | |||||
| ;; Authors: John Wiegley <jwiegley@gmail.com> | |||||
| ;; Thierry Volpiatto <thierry.volpiatto@gmail.com> | |||||
| ;; Keywords: dired async byte-compile | |||||
| ;; X-URL: https://github.com/jwiegley/dired-async | |||||
| ;; This program is free software; you can redistribute it and/or | |||||
| ;; modify it under the terms of the GNU General Public License as | |||||
| ;; published by the Free Software Foundation; either version 2, or (at | |||||
| ;; your option) any later version. | |||||
| ;; This program is distributed in the hope that it will be useful, but | |||||
| ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| ;; General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs; see the file COPYING. If not, write to the | |||||
| ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |||||
| ;; Boston, MA 02111-1307, USA. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;; This package provide the `async-byte-recompile-directory' function | |||||
| ;; which allows, as the name says to recompile a directory outside of | |||||
| ;; your running emacs. | |||||
| ;; The benefit is your files will be compiled in a clean environment without | |||||
| ;; the old *.el files loaded. | |||||
| ;; Among other things, this fix a bug in package.el which recompile | |||||
| ;; the new files in the current environment with the old files loaded, creating | |||||
| ;; errors in most packages after upgrades. | |||||
| ;; | |||||
| ;; NB: This package is advicing the function `package--compile'. | |||||
| ;;; Code: | |||||
| (require 'cl-lib) | |||||
| (require 'async) | |||||
| (defcustom async-bytecomp-allowed-packages '(async helm) | |||||
| "Packages in this list will be compiled asynchronously by `package--compile'. | |||||
| All the dependencies of these packages will be compiled async too, | |||||
| so no need to add dependencies to this list. | |||||
| The value of this variable can also be a list with a single element, | |||||
| the symbol `all', in this case packages are always compiled asynchronously." | |||||
| :group 'async | |||||
| :type '(repeat (choice symbol))) | |||||
| (defvar async-byte-compile-log-file "~/.emacs.d/async-bytecomp.log") | |||||
| (defun async-byte-recompile-directory (directory &optional quiet) | |||||
| "Compile all *.el files in DIRECTORY asynchronously. | |||||
| All *.elc files are systematically deleted before proceeding." | |||||
| (cl-loop with dir = (directory-files directory t "\\.elc\\'") | |||||
| unless dir return nil | |||||
| for f in dir | |||||
| when (file-exists-p f) do (delete-file f)) | |||||
| ;; Ensure async is reloaded when async.elc is deleted. | |||||
| ;; This happen when recompiling its own directory. | |||||
| (load "async") | |||||
| (let ((call-back | |||||
| `(lambda (&optional ignore) | |||||
| (if (file-exists-p async-byte-compile-log-file) | |||||
| (let ((buf (get-buffer-create byte-compile-log-buffer)) | |||||
| (n 0)) | |||||
| (with-current-buffer buf | |||||
| (goto-char (point-max)) | |||||
| (let ((inhibit-read-only t)) | |||||
| (insert-file-contents async-byte-compile-log-file) | |||||
| (compilation-mode)) | |||||
| (display-buffer buf) | |||||
| (delete-file async-byte-compile-log-file) | |||||
| (unless ,quiet | |||||
| (save-excursion | |||||
| (goto-char (point-min)) | |||||
| (while (re-search-forward "^.*:Error:" nil t) | |||||
| (cl-incf n))) | |||||
| (if (> n 0) | |||||
| (message "Failed to compile %d files in directory `%s'" n ,directory) | |||||
| (message "Directory `%s' compiled asynchronously with warnings" ,directory))))) | |||||
| (unless ,quiet | |||||
| (message "Directory `%s' compiled asynchronously with success" ,directory)))))) | |||||
| (async-start | |||||
| `(lambda () | |||||
| (require 'bytecomp) | |||||
| ,(async-inject-variables "\\`\\(load-path\\)\\|byte\\'") | |||||
| (let ((default-directory (file-name-as-directory ,directory)) | |||||
| error-data) | |||||
| (add-to-list 'load-path default-directory) | |||||
| (byte-recompile-directory ,directory 0 t) | |||||
| (when (get-buffer byte-compile-log-buffer) | |||||
| (setq error-data (with-current-buffer byte-compile-log-buffer | |||||
| (buffer-substring-no-properties (point-min) (point-max)))) | |||||
| (unless (string= error-data "") | |||||
| (with-temp-file ,async-byte-compile-log-file | |||||
| (erase-buffer) | |||||
| (insert error-data)))))) | |||||
| call-back) | |||||
| (message "Started compiling asynchronously directory %s" directory))) | |||||
| (defvar package-archive-contents) | |||||
| (declare-function package-desc-reqs "package.el" (cl-x)) | |||||
| (defun async-bytecomp--get-package-deps (pkg &optional only) | |||||
| (let* ((pkg-desc (cadr (assq pkg package-archive-contents))) | |||||
| (direct-deps (cl-loop for p in (package-desc-reqs pkg-desc) | |||||
| for name = (car p) | |||||
| when (assq name package-archive-contents) | |||||
| collect name)) | |||||
| (indirect-deps (unless (eq only 'direct) | |||||
| (delete-dups | |||||
| (cl-loop for p in direct-deps append | |||||
| (async-bytecomp--get-package-deps p)))))) | |||||
| (cl-case only | |||||
| (direct direct-deps) | |||||
| (separate (list direct-deps indirect-deps)) | |||||
| (indirect indirect-deps) | |||||
| (t (delete-dups (append direct-deps indirect-deps)))))) | |||||
| (defun async-bytecomp-get-allowed-pkgs () | |||||
| (when (and async-bytecomp-allowed-packages | |||||
| (listp async-bytecomp-allowed-packages)) | |||||
| (cl-loop for p in async-bytecomp-allowed-packages | |||||
| append (async-bytecomp--get-package-deps p) into reqs | |||||
| finally return | |||||
| (delete-dups | |||||
| (append async-bytecomp-allowed-packages reqs))))) | |||||
| (defadvice package--compile (around byte-compile-async activate) | |||||
| (let ((cur-package (package-desc-name pkg-desc))) | |||||
| (if (or (equal async-bytecomp-allowed-packages '(all)) | |||||
| (memq cur-package (async-bytecomp-get-allowed-pkgs))) | |||||
| (progn | |||||
| (when (eq cur-package 'async) | |||||
| (fmakunbound 'async-byte-recompile-directory)) | |||||
| (package-activate-1 pkg-desc) | |||||
| (load "async-bytecomp") ; emacs-24.3 don't reload new files. | |||||
| (async-byte-recompile-directory (package-desc-dir pkg-desc) t)) | |||||
| ad-do-it))) | |||||
| (provide 'async-bytecomp) | |||||
| ;;; async-bytecomp.el ends here | |||||
| @ -0,0 +1,4 @@ | |||||
| (define-package "async" "20150412.2207" "Asynchronous processing in Emacs" 'nil) | |||||
| ;; Local Variables: | |||||
| ;; no-byte-compile: t | |||||
| ;; End: | |||||
| @ -0,0 +1,292 @@ | |||||
| ;;; async --- Asynchronous processing in Emacs | |||||
| ;; Copyright (C) 2012~2014 John Wiegley | |||||
| ;; Author: John Wiegley <jwiegley@gmail.com> | |||||
| ;; Created: 18 Jun 2012 | |||||
| ;; Keywords: async | |||||
| ;; X-URL: https://github.com/jwiegley/emacs-async | |||||
| ;; This program is free software; you can redistribute it and/or | |||||
| ;; modify it under the terms of the GNU General Public License as | |||||
| ;; published by the Free Software Foundation; either version 2, or (at | |||||
| ;; your option) any later version. | |||||
| ;; This program is distributed in the hope that it will be useful, but | |||||
| ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| ;; General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs; see the file COPYING. If not, write to the | |||||
| ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |||||
| ;; Boston, MA 02111-1307, USA. | |||||
| ;;; Commentary: | |||||
| ;; Adds the ability to call asynchronous functions and process with ease. See | |||||
| ;; the documentation for `async-start' and `async-start-process'. | |||||
| ;;; Code: | |||||
| (defgroup async nil | |||||
| "Simple asynchronous processing in Emacs" | |||||
| :group 'emacs) | |||||
| (defvar async-debug nil) | |||||
| (defvar async-send-over-pipe t) | |||||
| (defvar async-in-child-emacs nil) | |||||
| (defvar async-callback nil) | |||||
| (defvar async-callback-for-process nil) | |||||
| (defvar async-callback-value nil) | |||||
| (defvar async-callback-value-set nil) | |||||
| (defvar async-current-process nil) | |||||
| (defun async-inject-variables | |||||
| (include-regexp &optional predicate exclude-regexp) | |||||
| "Return a `setq' form that replicates part of the calling environment. | |||||
| It sets the value for every variable matching INCLUDE-REGEXP and | |||||
| also PREDICATE. It will not perform injection for any variable | |||||
| matching EXCLUDE-REGEXP (if present). It is intended to be used | |||||
| as follows: | |||||
| (async-start | |||||
| `(lambda () | |||||
| (require 'smtpmail) | |||||
| (with-temp-buffer | |||||
| (insert ,(buffer-substring-no-properties (point-min) (point-max))) | |||||
| ;; Pass in the variable environment for smtpmail | |||||
| ,(async-inject-variables \"\\`\\(smtpmail\\|\\(user-\\)?mail\\)-\") | |||||
| (smtpmail-send-it))) | |||||
| 'ignore)" | |||||
| `(setq | |||||
| ,@(let (bindings) | |||||
| (mapatoms | |||||
| (lambda (sym) | |||||
| (if (and (boundp sym) | |||||
| (or (null include-regexp) | |||||
| (string-match include-regexp (symbol-name sym))) | |||||
| (not (string-match | |||||
| (or exclude-regexp "-syntax-table\\'") | |||||
| (symbol-name sym)))) | |||||
| (let ((value (symbol-value sym))) | |||||
| (when (or (null predicate) | |||||
| (funcall predicate sym)) | |||||
| (setq bindings (cons `(quote ,value) bindings) | |||||
| bindings (cons sym bindings))))))) | |||||
| bindings))) | |||||
| (defalias 'async-inject-environment 'async-inject-variables) | |||||
| (defun async-handle-result (func result buf) | |||||
| (if (null func) | |||||
| (progn | |||||
| (set (make-local-variable 'async-callback-value) result) | |||||
| (set (make-local-variable 'async-callback-value-set) t)) | |||||
| (unwind-protect | |||||
| (if (and (listp result) | |||||
| (eq 'async-signal (nth 0 result))) | |||||
| (signal (car (nth 1 result)) | |||||
| (cdr (nth 1 result))) | |||||
| (funcall func result)) | |||||
| (unless async-debug | |||||
| (kill-buffer buf))))) | |||||
| (defun async-when-done (proc &optional change) | |||||
| "Process sentinal used to retrieve the value from the child process." | |||||
| (when (eq 'exit (process-status proc)) | |||||
| (with-current-buffer (process-buffer proc) | |||||
| (let ((async-current-process proc)) | |||||
| (if (= 0 (process-exit-status proc)) | |||||
| (if async-callback-for-process | |||||
| (if async-callback | |||||
| (prog1 | |||||
| (funcall async-callback proc) | |||||
| (unless async-debug | |||||
| (kill-buffer (current-buffer)))) | |||||
| (set (make-local-variable 'async-callback-value) proc) | |||||
| (set (make-local-variable 'async-callback-value-set) t)) | |||||
| (goto-char (point-max)) | |||||
| (backward-sexp) | |||||
| (async-handle-result async-callback (read (current-buffer)) | |||||
| (current-buffer))) | |||||
| (set (make-local-variable 'async-callback-value) | |||||
| (list 'error | |||||
| (format "Async process '%s' failed with exit code %d" | |||||
| (process-name proc) (process-exit-status proc)))) | |||||
| (set (make-local-variable 'async-callback-value-set) t)))))) | |||||
| (defun async--receive-sexp (&optional stream) | |||||
| (let ((sexp (decode-coding-string (base64-decode-string | |||||
| (read stream)) 'utf-8-unix))) | |||||
| (if async-debug | |||||
| (message "Received sexp {{{%s}}}" (pp-to-string sexp))) | |||||
| (setq sexp (read sexp)) | |||||
| (if async-debug | |||||
| (message "Read sexp {{{%s}}}" (pp-to-string sexp))) | |||||
| (eval sexp))) | |||||
| (defun async--insert-sexp (sexp) | |||||
| (prin1 sexp (current-buffer)) | |||||
| ;; Just in case the string we're sending might contain EOF | |||||
| (encode-coding-region (point-min) (point-max) 'utf-8-unix) | |||||
| (base64-encode-region (point-min) (point-max) t) | |||||
| (goto-char (point-min)) (insert ?\") | |||||
| (goto-char (point-max)) (insert ?\" ?\n)) | |||||
| (defun async--transmit-sexp (process sexp) | |||||
| (with-temp-buffer | |||||
| (if async-debug | |||||
| (message "Transmitting sexp {{{%s}}}" (pp-to-string sexp))) | |||||
| (async--insert-sexp sexp) | |||||
| (process-send-region process (point-min) (point-max)))) | |||||
| (defun async-batch-invoke () | |||||
| "Called from the child Emacs process' command-line." | |||||
| (setq async-in-child-emacs t | |||||
| debug-on-error async-debug) | |||||
| (if debug-on-error | |||||
| (prin1 (funcall | |||||
| (async--receive-sexp (unless async-send-over-pipe | |||||
| command-line-args-left)))) | |||||
| (condition-case err | |||||
| (prin1 (funcall | |||||
| (async--receive-sexp (unless async-send-over-pipe | |||||
| command-line-args-left)))) | |||||
| (error | |||||
| (prin1 (list 'async-signal err)))))) | |||||
| (defun async-ready (future) | |||||
| "Query a FUTURE to see if the ready is ready -- i.e., if no blocking | |||||
| would result from a call to `async-get' on that FUTURE." | |||||
| (and (memq (process-status future) '(exit signal)) | |||||
| (with-current-buffer (process-buffer future) | |||||
| async-callback-value-set))) | |||||
| (defun async-wait (future) | |||||
| "Wait for FUTURE to become ready." | |||||
| (while (not (async-ready future)) | |||||
| (sit-for 0.05))) | |||||
| (defun async-get (future) | |||||
| "Get the value from an asynchronously function when it is ready. | |||||
| FUTURE is returned by `async-start' or `async-start-process' when | |||||
| its FINISH-FUNC is nil." | |||||
| (async-wait future) | |||||
| (with-current-buffer (process-buffer future) | |||||
| (async-handle-result #'identity async-callback-value (current-buffer)))) | |||||
| (defun async-message-p (value) | |||||
| "Return true of VALUE is an async.el message packet." | |||||
| (and (listp value) | |||||
| (plist-get value :async-message))) | |||||
| (defun async-send (&rest args) | |||||
| "Send the given messages to the asychronous Emacs PROCESS." | |||||
| (let ((args (append args '(:async-message t)))) | |||||
| (if async-in-child-emacs | |||||
| (if async-callback | |||||
| (funcall async-callback args)) | |||||
| (async--transmit-sexp (car args) (list 'quote (cdr args)))))) | |||||
| (defun async-receive (&rest args) | |||||
| "Send the given messages to the asychronous Emacs PROCESS." | |||||
| (async--receive-sexp)) | |||||
| ;;;###autoload | |||||
| (defun async-start-process (name program finish-func &rest program-args) | |||||
| "Start the executable PROGRAM asynchronously. See `async-start'. | |||||
| PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the | |||||
| process object when done. If FINISH-FUNC is nil, the future | |||||
| object will return the process object when the program is | |||||
| finished. Set DEFAULT-DIRECTORY to change PROGRAM's current | |||||
| working directory." | |||||
| (let* ((buf (generate-new-buffer (concat "*" name "*"))) | |||||
| (proc (let ((process-connection-type nil)) | |||||
| (apply #'start-process name buf program program-args)))) | |||||
| (with-current-buffer buf | |||||
| (set (make-local-variable 'async-callback) finish-func) | |||||
| (set-process-sentinel proc #'async-when-done) | |||||
| (unless (string= name "emacs") | |||||
| (set (make-local-variable 'async-callback-for-process) t)) | |||||
| proc))) | |||||
| ;;;###autoload | |||||
| (defmacro async-start (start-func &optional finish-func) | |||||
| "Execute START-FUNC (often a lambda) in a subordinate Emacs process. | |||||
| When done, the return value is passed to FINISH-FUNC. Example: | |||||
| (async-start | |||||
| ;; What to do in the child process | |||||
| (lambda () | |||||
| (message \"This is a test\") | |||||
| (sleep-for 3) | |||||
| 222) | |||||
| ;; What to do when it finishes | |||||
| (lambda (result) | |||||
| (message \"Async process done, result should be 222: %s\" | |||||
| result))) | |||||
| If FINISH-FUNC is nil or missing, a future is returned that can | |||||
| be inspected using `async-get', blocking until the value is | |||||
| ready. Example: | |||||
| (let ((proc (async-start | |||||
| ;; What to do in the child process | |||||
| (lambda () | |||||
| (message \"This is a test\") | |||||
| (sleep-for 3) | |||||
| 222)))) | |||||
| (message \"I'm going to do some work here\") ;; .... | |||||
| (message \"Waiting on async process, result should be 222: %s\" | |||||
| (async-get proc))) | |||||
| If you don't want to use a callback, and you don't care about any | |||||
| return value form the child process, pass the `ignore' symbol as | |||||
| the second argument (if you don't, and never call `async-get', it | |||||
| will leave *emacs* process buffers hanging around): | |||||
| (async-start | |||||
| (lambda () | |||||
| (delete-file \"a remote file on a slow link\" nil)) | |||||
| 'ignore) | |||||
| Note: Even when FINISH-FUNC is present, a future is still | |||||
| returned except that it yields no value (since the value is | |||||
| passed to FINISH-FUNC). Call `async-get' on such a future always | |||||
| returns nil. It can still be useful, however, as an argument to | |||||
| `async-ready' or `async-wait'." | |||||
| (require 'find-func) | |||||
| (let ((procvar (make-symbol "proc"))) | |||||
| `(let* ((sexp ,start-func) | |||||
| (,procvar | |||||
| (async-start-process | |||||
| "emacs" (file-truename | |||||
| (expand-file-name invocation-name | |||||
| invocation-directory)) | |||||
| ,finish-func | |||||
| "-Q" "-l" | |||||
| ;; Using `locate-library' ensure we use the right file | |||||
| ;; when the .elc have been deleted. | |||||
| ,(locate-library "async") | |||||
| "-batch" "-f" "async-batch-invoke" | |||||
| (if async-send-over-pipe | |||||
| "<none>" | |||||
| (with-temp-buffer | |||||
| (async--insert-sexp (list 'quote sexp)) | |||||
| (buffer-string)))))) | |||||
| (if async-send-over-pipe | |||||
| (async--transmit-sexp ,procvar (list 'quote sexp))) | |||||
| ,procvar))) | |||||
| (defmacro async-sandbox(func) | |||||
| "Evaluate FUNC in a separate Emacs process, synchronously." | |||||
| `(async-get (async-start ,func))) | |||||
| (provide 'async) | |||||
| ;;; async.el ends here | |||||
| @ -1,64 +0,0 @@ | |||||
| ;;; auto-complete-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil "auto-complete" "auto-complete.el" (21570 24553 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from auto-complete.el | |||||
| (autoload 'auto-complete "auto-complete" "\ | |||||
| Start auto-completion at current point. | |||||
| \(fn &optional SOURCES)" t nil) | |||||
| (autoload 'auto-complete-mode "auto-complete" "\ | |||||
| AutoComplete mode | |||||
| \(fn &optional ARG)" t nil) | |||||
| (defvar global-auto-complete-mode nil "\ | |||||
| Non-nil if Global-Auto-Complete mode is enabled. | |||||
| See the command `global-auto-complete-mode' for a description of this minor mode. | |||||
| Setting this variable directly does not take effect; | |||||
| either customize it (see the info node `Easy Customization') | |||||
| or call the function `global-auto-complete-mode'.") | |||||
| (custom-autoload 'global-auto-complete-mode "auto-complete" nil) | |||||
| (autoload 'global-auto-complete-mode "auto-complete" "\ | |||||
| Toggle Auto-Complete mode in all buffers. | |||||
| With prefix ARG, enable Global-Auto-Complete mode if ARG is positive; | |||||
| otherwise, disable it. If called from Lisp, enable the mode if | |||||
| ARG is omitted or nil. | |||||
| Auto-Complete mode is enabled in all buffers where | |||||
| `auto-complete-mode-maybe' would do it. | |||||
| See `auto-complete-mode' for more information on Auto-Complete mode. | |||||
| \(fn &optional ARG)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "auto-complete-config" "auto-complete-config.el" | |||||
| ;;;;;; (21570 24553 0 0)) | |||||
| ;;; Generated autoloads from auto-complete-config.el | |||||
| (autoload 'ac-config-default "auto-complete-config" "\ | |||||
| \(fn)" nil nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil nil ("auto-complete-pkg.el") (21570 24553 81515 | |||||
| ;;;;;; 0)) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; auto-complete-autoloads.el ends here | |||||
| @ -1,521 +0,0 @@ | |||||
| ;;; auto-complete-config.el --- auto-complete additional configuations | |||||
| ;; Copyright (C) 2009, 2010 Tomohiro Matsuyama | |||||
| ;; Author: Tomohiro Matsuyama <m2ym.pub@gmail.com> | |||||
| ;; Keywords: convenience | |||||
| ;; Version: 1.4 | |||||
| ;; This program is free software; you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; This program is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (eval-when-compile | |||||
| (require 'cl)) | |||||
| (require 'auto-complete) | |||||
| ;;;; Additional sources | |||||
| ;; imenu | |||||
| (defvar ac-imenu-index nil) | |||||
| (ac-clear-variable-every-10-minutes 'ac-imenu-index) | |||||
| (defun ac-imenu-candidates () | |||||
| (loop with i = 0 | |||||
| with stack = (progn | |||||
| (unless (local-variable-p 'ac-imenu-index) | |||||
| (make-local-variable 'ac-imenu-index)) | |||||
| (or ac-imenu-index | |||||
| (setq ac-imenu-index | |||||
| (ignore-errors | |||||
| (with-no-warnings | |||||
| (imenu--make-index-alist)))))) | |||||
| with result | |||||
| while (and stack (or (not (integerp ac-limit)) | |||||
| (< i ac-limit))) | |||||
| for node = (pop stack) | |||||
| if (consp node) | |||||
| do | |||||
| (let ((car (car node)) | |||||
| (cdr (cdr node))) | |||||
| (if (consp cdr) | |||||
| (mapc (lambda (child) | |||||
| (push child stack)) | |||||
| cdr) | |||||
| (when (and (stringp car) | |||||
| (string-match (concat "^" (regexp-quote ac-prefix)) car)) | |||||
| ;; Remove extra characters | |||||
| (if (string-match "^.*\\(()\\|=\\|<>\\)$" car) | |||||
| (setq car (substring car 0 (match-beginning 1)))) | |||||
| (push car result) | |||||
| (incf i)))) | |||||
| finally return (nreverse result))) | |||||
| (ac-define-source imenu | |||||
| '((depends imenu) | |||||
| (candidates . ac-imenu-candidates) | |||||
| (symbol . "s"))) | |||||
| ;; gtags | |||||
| (defface ac-gtags-candidate-face | |||||
| '((t (:inherit ac-candidate-face :foreground "navy"))) | |||||
| "Face for gtags candidate" | |||||
| :group 'auto-complete) | |||||
| (defface ac-gtags-selection-face | |||||
| '((t (:inherit ac-selection-face :background "navy"))) | |||||
| "Face for the gtags selected candidate." | |||||
| :group 'auto-complete) | |||||
| (defun ac-gtags-candidate () | |||||
| (ignore-errors | |||||
| (split-string (shell-command-to-string (format "global -ciq %s" ac-prefix)) "\n"))) | |||||
| (ac-define-source gtags | |||||
| '((candidates . ac-gtags-candidate) | |||||
| (candidate-face . ac-gtags-candidate-face) | |||||
| (selection-face . ac-gtags-selection-face) | |||||
| (requires . 3) | |||||
| (symbol . "s"))) | |||||
| ;; yasnippet | |||||
| (defface ac-yasnippet-candidate-face | |||||
| '((t (:inherit ac-candidate-face | |||||
| :background "sandybrown" :foreground "black"))) | |||||
| "Face for yasnippet candidate." | |||||
| :group 'auto-complete) | |||||
| (defface ac-yasnippet-selection-face | |||||
| '((t (:inherit ac-selection-face :background "coral3"))) | |||||
| "Face for the yasnippet selected candidate." | |||||
| :group 'auto-complete) | |||||
| (defun ac-yasnippet-table-hash (table) | |||||
| (cond | |||||
| ((fboundp 'yas/snippet-table-hash) | |||||
| (yas/snippet-table-hash table)) | |||||
| ((fboundp 'yas/table-hash) | |||||
| (yas/table-hash table)))) | |||||
| (defun ac-yasnippet-table-parent (table) | |||||
| (cond | |||||
| ((fboundp 'yas/snippet-table-parent) | |||||
| (yas/snippet-table-parent table)) | |||||
| ((fboundp 'yas/table-parent) | |||||
| (yas/table-parent table)))) | |||||
| (defun ac-yasnippet-candidate-1 (table) | |||||
| (with-no-warnings | |||||
| (let ((hashtab (ac-yasnippet-table-hash table)) | |||||
| (parent (ac-yasnippet-table-parent table)) | |||||
| candidates) | |||||
| (maphash (lambda (key value) | |||||
| (push key candidates)) | |||||
| hashtab) | |||||
| (setq candidates (all-completions ac-prefix (nreverse candidates))) | |||||
| (if parent | |||||
| (setq candidates | |||||
| (append candidates (ac-yasnippet-candidate-1 parent)))) | |||||
| candidates))) | |||||
| (defun ac-yasnippet-candidates () | |||||
| (with-no-warnings | |||||
| (cond (;; 0.8 onwards | |||||
| (fboundp 'yas-active-keys) | |||||
| (all-completions ac-prefix (yas-active-keys))) | |||||
| (;; >0.6.0 | |||||
| (fboundp 'yas/get-snippet-tables) | |||||
| (apply 'append (mapcar 'ac-yasnippet-candidate-1 | |||||
| (condition-case nil | |||||
| (yas/get-snippet-tables major-mode) | |||||
| (wrong-number-of-arguments | |||||
| (yas/get-snippet-tables))))) | |||||
| ) | |||||
| (t | |||||
| (let ((table | |||||
| (if (fboundp 'yas/snippet-table) | |||||
| ;; <0.6.0 | |||||
| (yas/snippet-table major-mode) | |||||
| ;; 0.6.0 | |||||
| (yas/current-snippet-table)))) | |||||
| (if table | |||||
| (ac-yasnippet-candidate-1 table))))))) | |||||
| (ac-define-source yasnippet | |||||
| '((depends yasnippet) | |||||
| (candidates . ac-yasnippet-candidates) | |||||
| (action . yas/expand) | |||||
| (candidate-face . ac-yasnippet-candidate-face) | |||||
| (selection-face . ac-yasnippet-selection-face) | |||||
| (symbol . "a"))) | |||||
| ;; semantic | |||||
| (defun ac-semantic-candidates (prefix) | |||||
| (with-no-warnings | |||||
| (delete "" ; semantic sometimes returns an empty string | |||||
| (mapcar (lambda (elem) | |||||
| (cons (semantic-tag-name elem) | |||||
| (semantic-tag-clone elem))) | |||||
| (ignore-errors | |||||
| (or (semantic-analyze-possible-completions | |||||
| (semantic-analyze-current-context)) | |||||
| (senator-find-tag-for-completion prefix))))))) | |||||
| (defun ac-semantic-doc (symbol) | |||||
| (with-no-warnings | |||||
| (let* ((proto (semantic-format-tag-summarize-with-file symbol nil t)) | |||||
| (doc (semantic-documentation-for-tag symbol)) | |||||
| (res proto)) | |||||
| (when doc | |||||
| (setq res (concat res "\n\n" doc))) | |||||
| res))) | |||||
| (ac-define-source semantic | |||||
| '((available . (or (require 'semantic-ia nil t) | |||||
| (require 'semantic/ia nil t))) | |||||
| (candidates . (ac-semantic-candidates ac-prefix)) | |||||
| (document . ac-semantic-doc) | |||||
| (prefix . cc-member) | |||||
| (requires . 0) | |||||
| (symbol . "m"))) | |||||
| (ac-define-source semantic-raw | |||||
| '((available . (or (require 'semantic-ia nil t) | |||||
| (require 'semantic/ia nil t))) | |||||
| (candidates . (ac-semantic-candidates ac-prefix)) | |||||
| (document . ac-semantic-doc) | |||||
| (symbol . "s"))) | |||||
| ;; eclim | |||||
| (defun ac-eclim-candidates () | |||||
| (with-no-warnings | |||||
| (loop for c in (eclim/java-complete) | |||||
| collect (nth 1 c)))) | |||||
| (ac-define-source eclim | |||||
| '((candidates . ac-eclim-candidates) | |||||
| (prefix . c-dot) | |||||
| (requires . 0) | |||||
| (symbol . "f"))) | |||||
| ;; css | |||||
| ;; Copied from company-css.el | |||||
| (defconst ac-css-property-alist | |||||
| ;; see http://www.w3.org/TR/CSS21/propidx.html | |||||
| '(("azimuth" angle "left-side" "far-left" "left" "center-left" "center" | |||||
| "center-right" "right" "far-right" "right-side" "behind" "leftwards" | |||||
| "rightwards") | |||||
| ("background" background-color background-image background-repeat | |||||
| background-attachment background-position) | |||||
| ("background-attachment" "scroll" "fixed") | |||||
| ("background-color" color "transparent") | |||||
| ("background-image" uri "none") | |||||
| ("background-position" percentage length "left" "center" "right" percentage | |||||
| length "top" "center" "bottom" "left" "center" "right" "top" "center" | |||||
| "bottom") | |||||
| ("background-repeat" "repeat" "repeat-x" "repeat-y" "no-repeat") | |||||
| ("border" border-width border-style border-color) | |||||
| ("border-bottom" border) | |||||
| ("border-bottom-color" border-color) | |||||
| ("border-bottom-style" border-style) | |||||
| ("border-bottom-width" border-width) | |||||
| ("border-collapse" "collapse" "separate") | |||||
| ("border-color" color "transparent") | |||||
| ("border-left" border) | |||||
| ("border-left-color" border-color) | |||||
| ("border-left-style" border-style) | |||||
| ("border-left-width" border-width) | |||||
| ("border-right" border) | |||||
| ("border-right-color" border-color) | |||||
| ("border-right-style" border-style) | |||||
| ("border-right-width" border-width) | |||||
| ("border-spacing" length length) | |||||
| ("border-style" border-style) | |||||
| ("border-top" border) | |||||
| ("border-top-color" border-color) | |||||
| ("border-top-style" border-style) | |||||
| ("border-top-width" border-width) | |||||
| ("border-width" border-width) | |||||
| ("bottom" length percentage "auto") | |||||
| ("caption-side" "top" "bottom") | |||||
| ("clear" "none" "left" "right" "both") | |||||
| ("clip" shape "auto") | |||||
| ("color" color) | |||||
| ("content" "normal" "none" string uri counter "attr()" "open-quote" | |||||
| "close-quote" "no-open-quote" "no-close-quote") | |||||
| ("counter-increment" identifier integer "none") | |||||
| ("counter-reset" identifier integer "none") | |||||
| ("cue" cue-before cue-after) | |||||
| ("cue-after" uri "none") | |||||
| ("cue-before" uri "none") | |||||
| ("cursor" uri "*" "auto" "crosshair" "default" "pointer" "move" "e-resize" | |||||
| "ne-resize" "nw-resize" "n-resize" "se-resize" "sw-resize" "s-resize" | |||||
| "w-resize" "text" "wait" "help" "progress") | |||||
| ("direction" "ltr" "rtl") | |||||
| ("display" "inline" "block" "list-item" "run-in" "inline-block" "table" | |||||
| "inline-table" "table-row-group" "table-header-group" "table-footer-group" | |||||
| "table-row" "table-column-group" "table-column" "table-cell" | |||||
| "table-caption" "none") | |||||
| ("elevation" angle "below" "level" "above" "higher" "lower") | |||||
| ("empty-cells" "show" "hide") | |||||
| ("float" "left" "right" "none") | |||||
| ("font" font-style font-variant font-weight font-size "/" line-height | |||||
| font-family "caption" "icon" "menu" "message-box" "small-caption" | |||||
| "status-bar") | |||||
| ("font-family" family-name generic-family) | |||||
| ("font-size" absolute-size relative-size length percentage) | |||||
| ("font-style" "normal" "italic" "oblique") | |||||
| ("font-variant" "normal" "small-caps") | |||||
| ("font-weight" "normal" "bold" "bolder" "lighter" "100" "200" "300" "400" | |||||
| "500" "600" "700" "800" "900") | |||||
| ("height" length percentage "auto") | |||||
| ("left" length percentage "auto") | |||||
| ("letter-spacing" "normal" length) | |||||
| ("line-height" "normal" number length percentage) | |||||
| ("list-style" list-style-type list-style-position list-style-image) | |||||
| ("list-style-image" uri "none") | |||||
| ("list-style-position" "inside" "outside") | |||||
| ("list-style-type" "disc" "circle" "square" "decimal" "decimal-leading-zero" | |||||
| "lower-roman" "upper-roman" "lower-greek" "lower-latin" "upper-latin" | |||||
| "armenian" "georgian" "lower-alpha" "upper-alpha" "none") | |||||
| ("margin" margin-width) | |||||
| ("margin-bottom" margin-width) | |||||
| ("margin-left" margin-width) | |||||
| ("margin-right" margin-width) | |||||
| ("margin-top" margin-width) | |||||
| ("max-height" length percentage "none") | |||||
| ("max-width" length percentage "none") | |||||
| ("min-height" length percentage) | |||||
| ("min-width" length percentage) | |||||
| ("orphans" integer) | |||||
| ("outline" outline-color outline-style outline-width) | |||||
| ("outline-color" color "invert") | |||||
| ("outline-style" border-style) | |||||
| ("outline-width" border-width) | |||||
| ("overflow" "visible" "hidden" "scroll" "auto") | |||||
| ("padding" padding-width) | |||||
| ("padding-bottom" padding-width) | |||||
| ("padding-left" padding-width) | |||||
| ("padding-right" padding-width) | |||||
| ("padding-top" padding-width) | |||||
| ("page-break-after" "auto" "always" "avoid" "left" "right") | |||||
| ("page-break-before" "auto" "always" "avoid" "left" "right") | |||||
| ("page-break-inside" "avoid" "auto") | |||||
| ("pause" time percentage) | |||||
| ("pause-after" time percentage) | |||||
| ("pause-before" time percentage) | |||||
| ("pitch" frequency "x-low" "low" "medium" "high" "x-high") | |||||
| ("pitch-range" number) | |||||
| ("play-during" uri "mix" "repeat" "auto" "none") | |||||
| ("position" "static" "relative" "absolute" "fixed") | |||||
| ("quotes" string string "none") | |||||
| ("richness" number) | |||||
| ("right" length percentage "auto") | |||||
| ("speak" "normal" "none" "spell-out") | |||||
| ("speak-header" "once" "always") | |||||
| ("speak-numeral" "digits" "continuous") | |||||
| ("speak-punctuation" "code" "none") | |||||
| ("speech-rate" number "x-slow" "slow" "medium" "fast" "x-fast" "faster" | |||||
| "slower") | |||||
| ("stress" number) | |||||
| ("table-layout" "auto" "fixed") | |||||
| ("text-align" "left" "right" "center" "justify") | |||||
| ("text-decoration" "none" "underline" "overline" "line-through" "blink") | |||||
| ("text-indent" length percentage) | |||||
| ("text-transform" "capitalize" "uppercase" "lowercase" "none") | |||||
| ("top" length percentage "auto") | |||||
| ("unicode-bidi" "normal" "embed" "bidi-override") | |||||
| ("vertical-align" "baseline" "sub" "super" "top" "text-top" "middle" | |||||
| "bottom" "text-bottom" percentage length) | |||||
| ("visibility" "visible" "hidden" "collapse") | |||||
| ("voice-family" specific-voice generic-voice "*" specific-voice | |||||
| generic-voice) | |||||
| ("volume" number percentage "silent" "x-soft" "soft" "medium" "loud" | |||||
| "x-loud") | |||||
| ("white-space" "normal" "pre" "nowrap" "pre-wrap" "pre-line") | |||||
| ("widows" integer) | |||||
| ("width" length percentage "auto") | |||||
| ("word-spacing" "normal" length) | |||||
| ("z-index" "auto" integer)) | |||||
| "A list of CSS properties and their possible values.") | |||||
| (defconst ac-css-value-classes | |||||
| '((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large" | |||||
| "xx-large") | |||||
| (border-style "none" "hidden" "dotted" "dashed" "solid" "double" "groove" | |||||
| "ridge" "inset" "outset") | |||||
| (color "aqua" "black" "blue" "fuchsia" "gray" "green" "lime" "maroon" "navy" | |||||
| "olive" "orange" "purple" "red" "silver" "teal" "white" "yellow" | |||||
| "rgb") | |||||
| (counter "counter") | |||||
| (family-name "Courier" "Helvetica" "Times") | |||||
| (generic-family "serif" "sans-serif" "cursive" "fantasy" "monospace") | |||||
| (generic-voice "male" "female" "child") | |||||
| (margin-width "auto") ;; length percentage | |||||
| (relative-size "larger" "smaller") | |||||
| (shape "rect") | |||||
| (uri "url")) | |||||
| "A list of CSS property value classes and their contents.") | |||||
| (defconst ac-css-pseudo-classes | |||||
| '("active" "after" "before" "first" "first-child" "first-letter" "first-line" | |||||
| "focus" "hover" "lang" "left" "link" "right" "visited") | |||||
| "Identifiers for CSS pseudo-elements and pseudo-classes.") | |||||
| (defvar ac-css-property nil | |||||
| "Current editing property.") | |||||
| (defun ac-css-prefix () | |||||
| (when (save-excursion (re-search-backward "\\_<\\(.+?\\)\\_>\\s *:[^;]*\\=" nil t)) | |||||
| (setq ac-css-property (match-string 1)) | |||||
| (or (ac-prefix-symbol) (point)))) | |||||
| (defun ac-css-property-candidates () | |||||
| (let ((list (assoc-default ac-css-property ac-css-property-alist))) | |||||
| (if list | |||||
| (loop with seen | |||||
| with value | |||||
| while (setq value (pop list)) | |||||
| if (symbolp value) | |||||
| do (unless (memq value seen) | |||||
| (push value seen) | |||||
| (setq list | |||||
| (append list | |||||
| (or (assoc-default value ac-css-value-classes) | |||||
| (assoc-default (symbol-name value) ac-css-property-alist))))) | |||||
| else collect value) | |||||
| ac-css-pseudo-classes))) | |||||
| (ac-define-source css-property | |||||
| '((candidates . ac-css-property-candidates) | |||||
| (prefix . ac-css-prefix) | |||||
| (requires . 0))) | |||||
| ;; slime | |||||
| (ac-define-source slime | |||||
| '((depends slime) | |||||
| (candidates . (car (slime-simple-completions ac-prefix))) | |||||
| (symbol . "s") | |||||
| (cache))) | |||||
| ;; ghc-mod | |||||
| (ac-define-source ghc-mod | |||||
| '((depends ghc) | |||||
| (candidates . (ghc-select-completion-symbol)) | |||||
| (symbol . "s") | |||||
| (cache))) | |||||
| ;;;; Not maintained sources | |||||
| ;; ropemacs | |||||
| (defvar ac-ropemacs-loaded nil) | |||||
| (defun ac-ropemacs-require () | |||||
| (with-no-warnings | |||||
| (unless ac-ropemacs-loaded | |||||
| (pymacs-load "ropemacs" "rope-") | |||||
| (if (boundp 'ropemacs-enable-autoimport) | |||||
| (setq ropemacs-enable-autoimport t)) | |||||
| (setq ac-ropemacs-loaded t)))) | |||||
| (defun ac-ropemacs-setup () | |||||
| (ac-ropemacs-require) | |||||
| ;(setq ac-sources (append (list 'ac-source-ropemacs) ac-sources)) | |||||
| (setq ac-omni-completion-sources '(("\\." ac-source-ropemacs)))) | |||||
| (defun ac-ropemacs-initialize () | |||||
| (autoload 'pymacs-apply "pymacs") | |||||
| (autoload 'pymacs-call "pymacs") | |||||
| (autoload 'pymacs-eval "pymacs" nil t) | |||||
| (autoload 'pymacs-exec "pymacs" nil t) | |||||
| (autoload 'pymacs-load "pymacs" nil t) | |||||
| (add-hook 'python-mode-hook 'ac-ropemacs-setup) | |||||
| t) | |||||
| (defvar ac-ropemacs-completions-cache nil) | |||||
| (defvar ac-source-ropemacs | |||||
| '((init | |||||
| . (lambda () | |||||
| (setq ac-ropemacs-completions-cache | |||||
| (mapcar | |||||
| (lambda (completion) | |||||
| (concat ac-prefix completion)) | |||||
| (ignore-errors | |||||
| (rope-completions)))))) | |||||
| (candidates . ac-ropemacs-completions-cache))) | |||||
| ;; rcodetools | |||||
| (defvar ac-source-rcodetools | |||||
| '((init . (lambda () | |||||
| (require 'rcodetools) | |||||
| (condition-case x | |||||
| (save-excursion | |||||
| (rct-exec-and-eval rct-complete-command-name "--completion-emacs-icicles")) | |||||
| (error) (setq rct-method-completion-table nil)))) | |||||
| (candidates . (lambda () | |||||
| (all-completions | |||||
| ac-prefix | |||||
| (mapcar | |||||
| (lambda (completion) | |||||
| (replace-regexp-in-string "\t.*$" "" (car completion))) | |||||
| rct-method-completion-table)))))) | |||||
| ;;;; Default settings | |||||
| (defun ac-common-setup () | |||||
| ;(add-to-list 'ac-sources 'ac-source-filename) | |||||
| ) | |||||
| (defun ac-emacs-lisp-mode-setup () | |||||
| (setq ac-sources (append '(ac-source-features ac-source-functions ac-source-yasnippet ac-source-variables ac-source-symbols) ac-sources))) | |||||
| (defun ac-cc-mode-setup () | |||||
| (setq ac-sources (append '(ac-source-yasnippet ac-source-gtags) ac-sources))) | |||||
| (defun ac-ruby-mode-setup ()) | |||||
| (defun ac-css-mode-setup () | |||||
| (setq ac-sources (append '(ac-source-css-property) ac-sources))) | |||||
| ;;;###autoload | |||||
| (defun ac-config-default () | |||||
| (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers)) | |||||
| (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup) | |||||
| (add-hook 'c-mode-common-hook 'ac-cc-mode-setup) | |||||
| (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup) | |||||
| (add-hook 'css-mode-hook 'ac-css-mode-setup) | |||||
| (add-hook 'auto-complete-mode-hook 'ac-common-setup) | |||||
| (global-auto-complete-mode t)) | |||||
| (provide 'auto-complete-config) | |||||
| ;;; auto-complete-config.el ends here | |||||
| @ -1,5 +0,0 @@ | |||||
| (define-package "auto-complete" "20140824.1658" "Auto Completion for GNU Emacs" | |||||
| '((popup "0.5.0"))) | |||||
| ;; Local Variables: | |||||
| ;; no-byte-compile: t | |||||
| ;; End: | |||||
| @ -1,84 +0,0 @@ | |||||
| alignas | |||||
| alignof | |||||
| and | |||||
| and_eq | |||||
| asm | |||||
| auto | |||||
| bitand | |||||
| bitor | |||||
| bool | |||||
| break | |||||
| case | |||||
| catch | |||||
| char | |||||
| char16_t | |||||
| char32_t | |||||
| class | |||||
| compl | |||||
| const | |||||
| const_cast | |||||
| constexpr | |||||
| continue | |||||
| decltype | |||||
| default | |||||
| delete | |||||
| do | |||||
| double | |||||
| dynamic_cast | |||||
| else | |||||
| enum | |||||
| explicit | |||||
| export | |||||
| extern | |||||
| false | |||||
| float | |||||
| for | |||||
| friend | |||||
| goto | |||||
| if | |||||
| inline | |||||
| int | |||||
| long | |||||
| mutable | |||||
| namespace | |||||
| new | |||||
| noexcept | |||||
| not | |||||
| not_eq | |||||
| nullptr | |||||
| operator | |||||
| or | |||||
| or_eq | |||||
| private | |||||
| protected | |||||
| public | |||||
| register | |||||
| reinterpret_cast | |||||
| return | |||||
| short | |||||
| signed | |||||
| sizeof | |||||
| static | |||||
| static_assert | |||||
| static_cast | |||||
| struct | |||||
| switch | |||||
| template | |||||
| this | |||||
| thread_local | |||||
| throw | |||||
| true | |||||
| try | |||||
| typedef | |||||
| typeid | |||||
| typename | |||||
| union | |||||
| unsigned | |||||
| using | |||||
| virtual | |||||
| void | |||||
| volatile | |||||
| wchar_t | |||||
| while | |||||
| xor | |||||
| xor_eq | |||||
| @ -1,44 +0,0 @@ | |||||
| auto | |||||
| _Alignas | |||||
| _Alignof | |||||
| _Atomic | |||||
| _Bool | |||||
| break | |||||
| case | |||||
| char | |||||
| _Complex | |||||
| const | |||||
| continue | |||||
| default | |||||
| do | |||||
| double | |||||
| else | |||||
| enum | |||||
| extern | |||||
| float | |||||
| for | |||||
| goto | |||||
| _Generic | |||||
| if | |||||
| _Imaginary | |||||
| inline | |||||
| int | |||||
| long | |||||
| _Noreturn | |||||
| register | |||||
| restrict | |||||
| return | |||||
| short | |||||
| signed | |||||
| sizeof | |||||
| static | |||||
| struct | |||||
| switch | |||||
| _Static_assert | |||||
| typedef | |||||
| _Thread_local | |||||
| union | |||||
| unsigned | |||||
| void | |||||
| volatile | |||||
| while | |||||
| @ -1,874 +0,0 @@ | |||||
| !important | |||||
| @font-face | |||||
| @font-feature-values | |||||
| @keyframes | |||||
| ActiveBorder | |||||
| ActiveCaption | |||||
| Alpha | |||||
| AppWorkspace | |||||
| Background | |||||
| Barn | |||||
| BasicImage | |||||
| Blinds | |||||
| Blur | |||||
| ButtonFace | |||||
| ButtonHighlight | |||||
| ButtonShadow | |||||
| ButtonText | |||||
| CaptionText | |||||
| CheckerBoard | |||||
| Chroma | |||||
| Compositor | |||||
| CradientWipe | |||||
| DXImageTransform | |||||
| DropShadow | |||||
| Emboss | |||||
| Engrave | |||||
| Fade | |||||
| FlipH | |||||
| FlipV | |||||
| Glow | |||||
| Gray | |||||
| GrayText | |||||
| Highlight | |||||
| HighlightText | |||||
| Hz | |||||
| ICMFilter | |||||
| InactiveBorder | |||||
| InactiveCaption | |||||
| InactiveCaptionText | |||||
| InfoBackground | |||||
| InfoText | |||||
| Inset | |||||
| Invert | |||||
| Iris | |||||
| Light | |||||
| MaskFilter | |||||
| Matrix | |||||
| Menu | |||||
| MenuText | |||||
| Microsoft | |||||
| MotionBlur | |||||
| Pixelate | |||||
| RadialWipe | |||||
| RandomBars | |||||
| RandomDissolve | |||||
| RevealTrans | |||||
| Scrollbar | |||||
| Shadow | |||||
| Slide | |||||
| Spiral | |||||
| Stretch | |||||
| Strips | |||||
| ThreeDDarkShadow | |||||
| ThreeDFace | |||||
| ThreeDHighlight | |||||
| ThreeDLightShadow | |||||
| ThreeDShadow | |||||
| Wave | |||||
| Wheel | |||||
| Window | |||||
| WindowFrame | |||||
| WindowText | |||||
| Xray | |||||
| Zigzag | |||||
| _azimuth | |||||
| _background | |||||
| _background-position-x | |||||
| _background-position-y | |||||
| _border | |||||
| _bottom | |||||
| _caption | |||||
| _clear | |||||
| _clip | |||||
| _color | |||||
| _content | |||||
| _counter | |||||
| _cue | |||||
| _cursor | |||||
| _direction | |||||
| _display | |||||
| _elevation | |||||
| _empty | |||||
| _filter | |||||
| _filter:progid:DXImageTransform.Microsoft | |||||
| _float | |||||
| _font | |||||
| _height | |||||
| _ime | |||||
| _ime-mode | |||||
| _layout | |||||
| _layout-flow | |||||
| _layout-grid | |||||
| _layout-grid-char | |||||
| _layout-grid-line | |||||
| _layout-grid-mode | |||||
| _layout-grid-type | |||||
| _left | |||||
| _letter | |||||
| _line | |||||
| _line-break | |||||
| _list | |||||
| _margin | |||||
| _orphans | |||||
| _outline | |||||
| _overflow | |||||
| _overflow-x | |||||
| _overflow-y | |||||
| _padding | |||||
| _page | |||||
| _pause | |||||
| _pitch | |||||
| _play | |||||
| _position | |||||
| _quotes | |||||
| _richness | |||||
| _right | |||||
| _ruby | |||||
| _ruby-align | |||||
| _ruby-overhang | |||||
| _ruby-position | |||||
| _scrollbar | |||||
| _scrollbar-3dlight-color | |||||
| _scrollbar-arrow-color | |||||
| _scrollbar-base-color | |||||
| _scrollbar-darkshadow-color | |||||
| _scrollbar-face-color | |||||
| _scrollbar-highlight-color | |||||
| _scrollbar-track-color | |||||
| _speak | |||||
| _speech | |||||
| _stress | |||||
| _table | |||||
| _text | |||||
| _text-align-last | |||||
| _text-autospace | |||||
| _text-justify | |||||
| _text-kashida-space | |||||
| _text-overflow | |||||
| _text-underline-position | |||||
| _top | |||||
| _unicode | |||||
| _vertical | |||||
| _visibility | |||||
| _voice | |||||
| _volume | |||||
| _white | |||||
| _widows | |||||
| _width | |||||
| _word | |||||
| _word-break | |||||
| _word-wrap | |||||
| _writing | |||||
| _writing-mode | |||||
| _z | |||||
| _zoom | |||||
| above | |||||
| active | |||||
| adjust | |||||
| after | |||||
| aliceblue | |||||
| align | |||||
| align-content | |||||
| align-items | |||||
| align-self | |||||
| always | |||||
| animation | |||||
| animation-delay | |||||
| animation-direction | |||||
| animation-duration | |||||
| animation-fill-mode | |||||
| animation-iteration-count | |||||
| animation-name | |||||
| animation-play-state | |||||
| animation-timing-function | |||||
| antiquewhite | |||||
| aqua | |||||
| aquamarine | |||||
| armenian | |||||
| arrow | |||||
| attachment | |||||
| auto | |||||
| autospace | |||||
| avoid | |||||
| azimuth | |||||
| azure | |||||
| backface-visibility | |||||
| background | |||||
| background-attachment | |||||
| background-clip | |||||
| background-color | |||||
| background-image | |||||
| background-origin | |||||
| background-position | |||||
| background-repeat | |||||
| background-size | |||||
| bar | |||||
| base | |||||
| baseline | |||||
| before | |||||
| behind | |||||
| beige | |||||
| below | |||||
| bidi | |||||
| bidi-override | |||||
| bisque | |||||
| black | |||||
| blanchedalmond | |||||
| blink | |||||
| block | |||||
| blue | |||||
| blueviolet | |||||
| bold | |||||
| bolder | |||||
| border | |||||
| border-bottom | |||||
| border-bottom-color | |||||
| border-bottom-left-radius | |||||
| border-bottom-right-radius | |||||
| border-bottom-style | |||||
| border-bottom-width | |||||
| border-collapse | |||||
| border-color | |||||
| border-image | |||||
| border-image-outset | |||||
| border-image-repeat | |||||
| border-image-slice | |||||
| border-image-source | |||||
| border-image-width | |||||
| border-left | |||||
| border-left-color | |||||
| border-left-style | |||||
| border-left-width | |||||
| border-radius | |||||
| border-right | |||||
| border-right-color | |||||
| border-right-style | |||||
| border-right-width | |||||
| border-spacing | |||||
| border-style | |||||
| border-top | |||||
| border-top-color | |||||
| border-top-left-radius | |||||
| border-top-right-radius | |||||
| border-top-style | |||||
| border-top-width | |||||
| border-width | |||||
| both | |||||
| bottom | |||||
| box | |||||
| box-decoration-break | |||||
| box-shadow | |||||
| box-sizing | |||||
| break | |||||
| break-after | |||||
| break-before | |||||
| break-inside | |||||
| brown | |||||
| burlwood | |||||
| cadetblue | |||||
| capitalize | |||||
| caps | |||||
| caption | |||||
| caption-side | |||||
| cell | |||||
| cells | |||||
| center | |||||
| center-left | |||||
| center-right | |||||
| char | |||||
| chartreuse | |||||
| chocolate | |||||
| circle | |||||
| cjk | |||||
| cjk-ideographic | |||||
| clear | |||||
| clip | |||||
| close | |||||
| close-quote | |||||
| cm | |||||
| code | |||||
| collapse | |||||
| color | |||||
| column | |||||
| column-count | |||||
| column-fill | |||||
| column-gap | |||||
| column-rule | |||||
| column-rule-color | |||||
| column-rule-style | |||||
| column-rule-width | |||||
| column-span | |||||
| column-width | |||||
| columns | |||||
| compact | |||||
| condensed | |||||
| content | |||||
| continuous | |||||
| coral | |||||
| cornflowerblue | |||||
| cornsilk | |||||
| counter | |||||
| counter-increment | |||||
| counter-reset | |||||
| crimson | |||||
| crop | |||||
| cross | |||||
| crosshair | |||||
| cue | |||||
| cue-after | |||||
| cue-before | |||||
| cursive | |||||
| cursor | |||||
| cyan | |||||
| darkblue | |||||
| darkcyan | |||||
| darkgoldenrod | |||||
| darkgray | |||||
| darkgreen | |||||
| darkkhaki | |||||
| darkmagenta | |||||
| darkolivegreen | |||||
| darkorange | |||||
| darkorchid | |||||
| darkred | |||||
| darksalmon | |||||
| darkseagreen | |||||
| darkshadow | |||||
| darkslateblue | |||||
| darkslategray | |||||
| darkturquoise | |||||
| darkviolet | |||||
| dashed | |||||
| decimal | |||||
| decimal-leading-zero | |||||
| decoration | |||||
| deeppink | |||||
| deepskyblue | |||||
| default | |||||
| deg | |||||
| digits | |||||
| dimgray | |||||
| direction | |||||
| disc | |||||
| display | |||||
| dodgerblue | |||||
| dotted | |||||
| double | |||||
| during | |||||
| e | |||||
| e-resize | |||||
| elevation | |||||
| em | |||||
| embed | |||||
| empty | |||||
| empty-cells | |||||
| ex | |||||
| expanded | |||||
| extra | |||||
| extra-condensed | |||||
| extra-expanded | |||||
| face | |||||
| family | |||||
| fantasy | |||||
| far | |||||
| far-left | |||||
| far-right | |||||
| fast | |||||
| faster | |||||
| filter | |||||
| firebrick | |||||
| first | |||||
| first-child | |||||
| first-letter | |||||
| first-line | |||||
| fixed | |||||
| flex | |||||
| flex-basis | |||||
| flex-direction | |||||
| flex-flow | |||||
| flex-grow | |||||
| flex-shrink | |||||
| flex-wrap | |||||
| float | |||||
| floralwhite | |||||
| flow | |||||
| focus | |||||
| font | |||||
| font-family | |||||
| font-feature-setting | |||||
| font-kerning | |||||
| font-language-override | |||||
| font-size | |||||
| font-size-adjust | |||||
| font-stretch | |||||
| font-style | |||||
| font-synthesis | |||||
| font-variant | |||||
| font-variant-alternates | |||||
| font-variant-caps | |||||
| font-variant-east-asian | |||||
| font-variant-ligatures | |||||
| font-variant-numeric | |||||
| font-variant-position | |||||
| font-weight | |||||
| footer | |||||
| forestgreen | |||||
| fuchsia | |||||
| gainsboro | |||||
| georgian | |||||
| ghostwhite | |||||
| gold | |||||
| goldenrod | |||||
| gray | |||||
| greek | |||||
| green | |||||
| greenyellow | |||||
| grid | |||||
| groove | |||||
| group | |||||
| hanging-punctuation | |||||
| header | |||||
| hebrew | |||||
| height | |||||
| help | |||||
| hidden | |||||
| hide | |||||
| high | |||||
| higher | |||||
| hiragana | |||||
| hiragana-iroha | |||||
| honeydew | |||||
| hotpink | |||||
| hover | |||||
| hyphens | |||||
| icon | |||||
| ideographic | |||||
| image | |||||
| image-orientation | |||||
| image-rendering | |||||
| image-resolution | |||||
| ime-mode | |||||
| in | |||||
| increment | |||||
| indent | |||||
| index | |||||
| indianred | |||||
| indigo | |||||
| inherit | |||||
| inline | |||||
| inline-block | |||||
| inline-table | |||||
| inset | |||||
| inside | |||||
| iroha | |||||
| italic | |||||
| item | |||||
| ivory | |||||
| justify | |||||
| justify-content | |||||
| kHz | |||||
| kashida | |||||
| katakana | |||||
| katakana-iroha | |||||
| khaki | |||||
| landscape | |||||
| lang() | |||||
| large | |||||
| larger | |||||
| last | |||||
| latin | |||||
| lavender | |||||
| lavenderblush | |||||
| lawngreen | |||||
| layout | |||||
| leading | |||||
| left | |||||
| left-side | |||||
| leftwards | |||||
| lenonchiffon | |||||
| letter | |||||
| letter-spacing | |||||
| level | |||||
| lightblue | |||||
| lightcoral | |||||
| lightcyan | |||||
| lighter | |||||
| lightgoldenrodyellow | |||||
| lightgray | |||||
| lightgreen | |||||
| lightgrey | |||||
| lightpink | |||||
| lightsalmon | |||||
| lightseagreen | |||||
| lightskyblue | |||||
| lightslategray | |||||
| lightsteelblue | |||||
| lightyellow | |||||
| lime | |||||
| limegreen | |||||
| line | |||||
| line-break | |||||
| line-height | |||||
| line-through | |||||
| linen | |||||
| link | |||||
| list | |||||
| list-item | |||||
| list-style | |||||
| list-style-image | |||||
| list-style-position | |||||
| list-style-type | |||||
| loud | |||||
| low | |||||
| lower | |||||
| lower-alpha | |||||
| lower-greek | |||||
| lower-latin | |||||
| lower-roman | |||||
| lowercase | |||||
| ltr | |||||
| magenta | |||||
| margin | |||||
| margin-bottom | |||||
| margin-left | |||||
| margin-right | |||||
| margin-top | |||||
| mark | |||||
| mark-after | |||||
| mark-before | |||||
| marker | |||||
| marker-offset | |||||
| marks | |||||
| maroon | |||||
| marquee-direction | |||||
| marquee-play-count | |||||
| marquee-speed | |||||
| marquee-style | |||||
| mask | |||||
| mask-type | |||||
| max | |||||
| max-height | |||||
| max-width | |||||
| medium | |||||
| mediumaquamarine | |||||
| mediumblue | |||||
| mediumorchid | |||||
| mediumpurple | |||||
| mediumseagreen | |||||
| mediumslateblue | |||||
| mediumspringgreen | |||||
| mediumturquoise | |||||
| mediumvioletred | |||||
| menu | |||||
| message | |||||
| message-box | |||||
| middle | |||||
| midnightblue | |||||
| min | |||||
| min-height | |||||
| min-width | |||||
| mintcream | |||||
| mistyrose | |||||
| mix | |||||
| mm | |||||
| moccasin | |||||
| mode | |||||
| monospace | |||||
| move | |||||
| ms | |||||
| n | |||||
| n-resize | |||||
| naby | |||||
| narrower | |||||
| nav-down | |||||
| nav-index | |||||
| nav-left | |||||
| nav-right | |||||
| nav-up | |||||
| navajowhite | |||||
| ne | |||||
| ne-resize | |||||
| no | |||||
| no-close-quote | |||||
| no-open-quote | |||||
| no-repeat | |||||
| none | |||||
| normal | |||||
| nowrap | |||||
| number | |||||
| numeral | |||||
| nw | |||||
| nw-resize | |||||
| object-fit | |||||
| object-position | |||||
| oblique | |||||
| offset | |||||
| oldlace | |||||
| olive | |||||
| olivedrab | |||||
| once | |||||
| opacity | |||||
| open | |||||
| open-quote | |||||
| orange | |||||
| orangered | |||||
| orchid | |||||
| order | |||||
| orphans | |||||
| out | |||||
| outline | |||||
| outline-color | |||||
| outline-offset | |||||
| outline-style | |||||
| outline-width | |||||
| outset | |||||
| outside | |||||
| overflow | |||||
| overflow-wrap | |||||
| overflow-x | |||||
| overflow-y | |||||
| overhang | |||||
| overline | |||||
| override | |||||
| padding | |||||
| padding-bottom | |||||
| padding-left | |||||
| padding-right | |||||
| padding-top | |||||
| page | |||||
| page-break-after | |||||
| page-break-before | |||||
| page-break-inside | |||||
| palegoldenrod | |||||
| palegreen | |||||
| paleturquoise | |||||
| palevioletred | |||||
| papayawhip | |||||
| pause | |||||
| pause-after | |||||
| pause-before | |||||
| pc | |||||
| peachpuff | |||||
| perspective | |||||
| perspective-origin | |||||
| peru | |||||
| phonemes | |||||
| pink | |||||
| pitch | |||||
| pitch-range | |||||
| play | |||||
| play-during | |||||
| plum | |||||
| pointer | |||||
| portarait | |||||
| position | |||||
| powderblue | |||||
| pre | |||||
| pre-line | |||||
| pre-wrap | |||||
| progid | |||||
| progress | |||||
| pt | |||||
| punctuation | |||||
| purple | |||||
| px | |||||
| quote | |||||
| quotes | |||||
| rad | |||||
| range | |||||
| rate | |||||
| red | |||||
| relative | |||||
| repeat | |||||
| repeat-x | |||||
| repeat-y | |||||
| reset | |||||
| resize | |||||
| rest | |||||
| rest-after | |||||
| rest-before | |||||
| richness | |||||
| ridge | |||||
| right | |||||
| right-side | |||||
| rightwards | |||||
| roman | |||||
| rosybrown | |||||
| row | |||||
| royalblue | |||||
| rtl | |||||
| run | |||||
| run-in | |||||
| s | |||||
| s-resize | |||||
| saddlebrown | |||||
| salmon | |||||
| sandybrown | |||||
| sans-serif | |||||
| scroll | |||||
| se | |||||
| se-resize | |||||
| seagreen | |||||
| seashell | |||||
| semi | |||||
| semi-condensed | |||||
| semi-expanded | |||||
| separate | |||||
| serif | |||||
| shadow | |||||
| show | |||||
| side | |||||
| sienna | |||||
| silent | |||||
| silever | |||||
| silver | |||||
| size | |||||
| skyblue | |||||
| slateblue | |||||
| slategray | |||||
| slow | |||||
| slower | |||||
| small | |||||
| small-caps | |||||
| small-caption | |||||
| smaller | |||||
| snow | |||||
| soft | |||||
| solid | |||||
| space | |||||
| spacing | |||||
| speak | |||||
| speak-header | |||||
| speak-numeral | |||||
| speak-punctuation | |||||
| specific | |||||
| specific-voice | |||||
| speech | |||||
| speech-rate | |||||
| spell | |||||
| spell-out | |||||
| springgreen | |||||
| square | |||||
| static | |||||
| status | |||||
| status-bar | |||||
| steelblue | |||||
| stress | |||||
| stretch | |||||
| style | |||||
| sub | |||||
| super | |||||
| sw | |||||
| sw-resize | |||||
| tab-size | |||||
| table | |||||
| table-caption | |||||
| table-cell | |||||
| table-column | |||||
| table-column-group | |||||
| table-footer-group | |||||
| table-header-group | |||||
| table-layout | |||||
| table-row | |||||
| table-row-group | |||||
| tan | |||||
| teal | |||||
| text | |||||
| text-align | |||||
| text-align-last | |||||
| text-bottom | |||||
| text-combine-horizontal | |||||
| text-decoration | |||||
| text-decoration-color | |||||
| text-decoration-line | |||||
| text-decoration-style | |||||
| text-indent | |||||
| text-justify | |||||
| text-orientation | |||||
| text-overflow | |||||
| text-shadow | |||||
| text-top | |||||
| text-transform | |||||
| text-underline-position | |||||
| thick | |||||
| thin | |||||
| thistle | |||||
| through | |||||
| tomato | |||||
| top | |||||
| track | |||||
| transform | |||||
| transform-origin | |||||
| transform-style | |||||
| transition | |||||
| transition-delay | |||||
| transition-duration | |||||
| transition-property | |||||
| transition-timing-function | |||||
| transparent | |||||
| turquoise | |||||
| type | |||||
| ultra | |||||
| ultra-condensed | |||||
| ultra-expanded | |||||
| underline | |||||
| unicode | |||||
| unicode-bidi | |||||
| upper | |||||
| upper-alpha | |||||
| upper-latin | |||||
| upper-roman | |||||
| uppercase | |||||
| variant | |||||
| vertical | |||||
| vertical-align | |||||
| violet | |||||
| visibility | |||||
| visible | |||||
| visited | |||||
| voice | |||||
| voice-balance | |||||
| voice-duration | |||||
| voice-family | |||||
| voice-pitch | |||||
| voice-pitch-range | |||||
| voice-rate | |||||
| voice-stress | |||||
| voice-volume | |||||
| volume | |||||
| w | |||||
| w-resize | |||||
| wait | |||||
| weight | |||||
| wheat | |||||
| white | |||||
| white-space | |||||
| whitesmoke | |||||
| wider | |||||
| widows | |||||
| width | |||||
| word | |||||
| word-break | |||||
| word-spacing | |||||
| word-wrap | |||||
| wrap | |||||
| writing-mode | |||||
| x | |||||
| x-fast | |||||
| x-high | |||||
| x-large | |||||
| x-loud | |||||
| x-low | |||||
| x-slow | |||||
| x-small | |||||
| x-soft | |||||
| xx | |||||
| xx-large | |||||
| xx-small | |||||
| y | |||||
| yellow | |||||
| yellowgreen | |||||
| z | |||||
| z-index | |||||
| zero | |||||
| @ -0,0 +1,64 @@ | |||||
| ;;; auto-complete-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil "auto-complete" "auto-complete.el" (21837 24217 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from auto-complete.el | |||||
| (autoload 'auto-complete "auto-complete" "\ | |||||
| Start auto-completion at current point. | |||||
| \(fn &optional SOURCES)" t nil) | |||||
| (autoload 'auto-complete-mode "auto-complete" "\ | |||||
| AutoComplete mode | |||||
| \(fn &optional ARG)" t nil) | |||||
| (defvar global-auto-complete-mode nil "\ | |||||
| Non-nil if Global-Auto-Complete mode is enabled. | |||||
| See the command `global-auto-complete-mode' for a description of this minor mode. | |||||
| Setting this variable directly does not take effect; | |||||
| either customize it (see the info node `Easy Customization') | |||||
| or call the function `global-auto-complete-mode'.") | |||||
| (custom-autoload 'global-auto-complete-mode "auto-complete" nil) | |||||
| (autoload 'global-auto-complete-mode "auto-complete" "\ | |||||
| Toggle Auto-Complete mode in all buffers. | |||||
| With prefix ARG, enable Global-Auto-Complete mode if ARG is positive; | |||||
| otherwise, disable it. If called from Lisp, enable the mode if | |||||
| ARG is omitted or nil. | |||||
| Auto-Complete mode is enabled in all buffers where | |||||
| `auto-complete-mode-maybe' would do it. | |||||
| See `auto-complete-mode' for more information on Auto-Complete mode. | |||||
| \(fn &optional ARG)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "auto-complete-config" "auto-complete-config.el" | |||||
| ;;;;;; (21837 24217 0 0)) | |||||
| ;;; Generated autoloads from auto-complete-config.el | |||||
| (autoload 'ac-config-default "auto-complete-config" "\ | |||||
| \(fn)" nil nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil nil ("auto-complete-pkg.el") (21837 24217 489567 | |||||
| ;;;;;; 0)) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; auto-complete-autoloads.el ends here | |||||
| @ -0,0 +1,543 @@ | |||||
| ;;; auto-complete-config.el --- auto-complete additional configuations | |||||
| ;; Copyright (C) 2009, 2010 Tomohiro Matsuyama | |||||
| ;; Author: Tomohiro Matsuyama <m2ym.pub@gmail.com> | |||||
| ;; Keywords: convenience | |||||
| ;; Version: 1.5.0 | |||||
| ;; This program is free software; you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; This program is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'cl-lib) | |||||
| (require 'auto-complete) | |||||
| ;;;; Additional sources | |||||
| ;; imenu | |||||
| (defvar ac-imenu-index nil) | |||||
| (ac-clear-variable-every-10-minutes 'ac-imenu-index) | |||||
| (defun ac-imenu-candidates () | |||||
| (cl-loop with i = 0 | |||||
| with stack = (progn | |||||
| (unless (local-variable-p 'ac-imenu-index) | |||||
| (make-local-variable 'ac-imenu-index)) | |||||
| (or ac-imenu-index | |||||
| (setq ac-imenu-index | |||||
| (ignore-errors | |||||
| (with-no-warnings | |||||
| (imenu--make-index-alist)))))) | |||||
| with result | |||||
| while (and stack (or (not (integerp ac-limit)) | |||||
| (< i ac-limit))) | |||||
| for node = (pop stack) | |||||
| if (consp node) | |||||
| do | |||||
| (let ((car (car node)) | |||||
| (cdr (cdr node))) | |||||
| (if (consp cdr) | |||||
| (mapc (lambda (child) | |||||
| (push child stack)) | |||||
| cdr) | |||||
| (when (and (stringp car) | |||||
| (string-match (concat "^" (regexp-quote ac-prefix)) car)) | |||||
| ;; Remove extra characters | |||||
| (if (string-match "^.*\\(()\\|=\\|<>\\)$" car) | |||||
| (setq car (substring car 0 (match-beginning 1)))) | |||||
| (push car result) | |||||
| (cl-incf i)))) | |||||
| finally return (nreverse result))) | |||||
| (ac-define-source imenu | |||||
| '((depends imenu) | |||||
| (candidates . ac-imenu-candidates) | |||||
| (symbol . "s"))) | |||||
| ;; gtags | |||||
| (defface ac-gtags-candidate-face | |||||
| '((t (:inherit ac-candidate-face :foreground "navy"))) | |||||
| "Face for gtags candidate" | |||||
| :group 'auto-complete) | |||||
| (defface ac-gtags-selection-face | |||||
| '((t (:inherit ac-selection-face :background "navy"))) | |||||
| "Face for the gtags selected candidate." | |||||
| :group 'auto-complete) | |||||
| (defun ac-gtags-candidate () | |||||
| (ignore-errors | |||||
| (split-string (shell-command-to-string (format "global -ciq %s" ac-prefix)) "\n"))) | |||||
| (ac-define-source gtags | |||||
| '((candidates . ac-gtags-candidate) | |||||
| (candidate-face . ac-gtags-candidate-face) | |||||
| (selection-face . ac-gtags-selection-face) | |||||
| (requires . 3) | |||||
| (symbol . "s"))) | |||||
| ;; yasnippet | |||||
| (defface ac-yasnippet-candidate-face | |||||
| '((t (:inherit ac-candidate-face | |||||
| :background "sandybrown" :foreground "black"))) | |||||
| "Face for yasnippet candidate." | |||||
| :group 'auto-complete) | |||||
| (defface ac-yasnippet-selection-face | |||||
| '((t (:inherit ac-selection-face :background "coral3"))) | |||||
| "Face for the yasnippet selected candidate." | |||||
| :group 'auto-complete) | |||||
| (defun ac-yasnippet-table-hash (table) | |||||
| (cond | |||||
| ((fboundp 'yas/snippet-table-hash) | |||||
| (yas/snippet-table-hash table)) | |||||
| ((fboundp 'yas/table-hash) | |||||
| (yas/table-hash table)))) | |||||
| (defun ac-yasnippet-table-parent (table) | |||||
| (cond | |||||
| ((fboundp 'yas/snippet-table-parent) | |||||
| (yas/snippet-table-parent table)) | |||||
| ((fboundp 'yas/table-parent) | |||||
| (yas/table-parent table)))) | |||||
| (defun ac-yasnippet-candidate-1 (table) | |||||
| (with-no-warnings | |||||
| (let ((hashtab (ac-yasnippet-table-hash table)) | |||||
| (parent (ac-yasnippet-table-parent table)) | |||||
| candidates) | |||||
| (maphash (lambda (key value) | |||||
| (push key candidates)) | |||||
| hashtab) | |||||
| (setq candidates (all-completions ac-prefix (nreverse candidates))) | |||||
| (if parent | |||||
| (setq candidates | |||||
| (append candidates (ac-yasnippet-candidate-1 parent)))) | |||||
| candidates))) | |||||
| (defun ac-yasnippet-candidates () | |||||
| (with-no-warnings | |||||
| (cond (;; 0.8 onwards | |||||
| (fboundp 'yas-active-keys) | |||||
| (all-completions ac-prefix (yas-active-keys))) | |||||
| (;; >0.6.0 | |||||
| (fboundp 'yas/get-snippet-tables) | |||||
| (apply 'append (mapcar 'ac-yasnippet-candidate-1 | |||||
| (condition-case nil | |||||
| (yas/get-snippet-tables major-mode) | |||||
| (wrong-number-of-arguments | |||||
| (yas/get-snippet-tables))))) | |||||
| ) | |||||
| (t | |||||
| (let ((table | |||||
| (if (fboundp 'yas/snippet-table) | |||||
| ;; <0.6.0 | |||||
| (yas/snippet-table major-mode) | |||||
| ;; 0.6.0 | |||||
| (yas/current-snippet-table)))) | |||||
| (if table | |||||
| (ac-yasnippet-candidate-1 table))))))) | |||||
| (ac-define-source yasnippet | |||||
| '((depends yasnippet) | |||||
| (candidates . ac-yasnippet-candidates) | |||||
| (action . yas/expand) | |||||
| (candidate-face . ac-yasnippet-candidate-face) | |||||
| (selection-face . ac-yasnippet-selection-face) | |||||
| (symbol . "a"))) | |||||
| ;; semantic | |||||
| (defun ac-semantic-candidates (prefix) | |||||
| (with-no-warnings | |||||
| (delete "" ; semantic sometimes returns an empty string | |||||
| (mapcar (lambda (elem) | |||||
| (cons (semantic-tag-name elem) | |||||
| (semantic-tag-clone elem))) | |||||
| (ignore-errors | |||||
| (or (semantic-analyze-possible-completions | |||||
| (semantic-analyze-current-context)) | |||||
| (senator-find-tag-for-completion prefix))))))) | |||||
| (defun ac-semantic-doc (symbol) | |||||
| (with-no-warnings | |||||
| (let* ((proto (semantic-format-tag-summarize-with-file symbol nil t)) | |||||
| (doc (semantic-documentation-for-tag symbol)) | |||||
| (res proto)) | |||||
| (when doc | |||||
| (setq res (concat res "\n\n" doc))) | |||||
| res))) | |||||
| (defun ac-semantic-action () | |||||
| (when (and (boundp 'yas-minor-mode) yas-minor-mode) | |||||
| (let* ((tag (car (last (oref (semantic-analyze-current-context) prefix)))) | |||||
| (class (semantic-tag-class tag)) | |||||
| (args)) | |||||
| (when (eq class 'function) | |||||
| (setq args (semantic-tag-function-arguments tag)) | |||||
| (yas-expand-snippet | |||||
| (concat "(" | |||||
| (mapconcat | |||||
| (lambda (arg) | |||||
| (let ((arg-type (semantic-format-tag-type arg nil)) | |||||
| (arg-name (semantic-format-tag-name arg nil))) | |||||
| (concat "${" | |||||
| (if (string= arg-name "") | |||||
| arg-type | |||||
| (concat arg-type " " arg-name)) | |||||
| "}"))) | |||||
| args | |||||
| ", ") | |||||
| ")$0")))))) | |||||
| (ac-define-source semantic | |||||
| '((available . (or (require 'semantic-ia nil t) | |||||
| (require 'semantic/ia nil t))) | |||||
| (candidates . (ac-semantic-candidates ac-prefix)) | |||||
| (document . ac-semantic-doc) | |||||
| (action . ac-semantic-action) | |||||
| (prefix . cc-member) | |||||
| (requires . 0) | |||||
| (symbol . "m"))) | |||||
| (ac-define-source semantic-raw | |||||
| '((available . (or (require 'semantic-ia nil t) | |||||
| (require 'semantic/ia nil t))) | |||||
| (candidates . (ac-semantic-candidates ac-prefix)) | |||||
| (document . ac-semantic-doc) | |||||
| (action . ac-semantic-action) | |||||
| (symbol . "s"))) | |||||
| ;; eclim | |||||
| (defun ac-eclim-candidates () | |||||
| (with-no-warnings | |||||
| (cl-loop for c in (eclim/java-complete) | |||||
| collect (nth 1 c)))) | |||||
| (ac-define-source eclim | |||||
| '((candidates . ac-eclim-candidates) | |||||
| (prefix . c-dot) | |||||
| (requires . 0) | |||||
| (symbol . "f"))) | |||||
| ;; css | |||||
| ;; Copied from company-css.el | |||||
| (defconst ac-css-property-alist | |||||
| ;; see http://www.w3.org/TR/CSS21/propidx.html | |||||
| '(("azimuth" angle "left-side" "far-left" "left" "center-left" "center" | |||||
| "center-right" "right" "far-right" "right-side" "behind" "leftwards" | |||||
| "rightwards") | |||||
| ("background" background-color background-image background-repeat | |||||
| background-attachment background-position) | |||||
| ("background-attachment" "scroll" "fixed") | |||||
| ("background-color" color "transparent") | |||||
| ("background-image" uri "none") | |||||
| ("background-position" percentage length "left" "center" "right" percentage | |||||
| length "top" "center" "bottom" "left" "center" "right" "top" "center" | |||||
| "bottom") | |||||
| ("background-repeat" "repeat" "repeat-x" "repeat-y" "no-repeat") | |||||
| ("border" border-width border-style border-color) | |||||
| ("border-bottom" border) | |||||
| ("border-bottom-color" border-color) | |||||
| ("border-bottom-style" border-style) | |||||
| ("border-bottom-width" border-width) | |||||
| ("border-collapse" "collapse" "separate") | |||||
| ("border-color" color "transparent") | |||||
| ("border-left" border) | |||||
| ("border-left-color" border-color) | |||||
| ("border-left-style" border-style) | |||||
| ("border-left-width" border-width) | |||||
| ("border-right" border) | |||||
| ("border-right-color" border-color) | |||||
| ("border-right-style" border-style) | |||||
| ("border-right-width" border-width) | |||||
| ("border-spacing" length length) | |||||
| ("border-style" border-style) | |||||
| ("border-top" border) | |||||
| ("border-top-color" border-color) | |||||
| ("border-top-style" border-style) | |||||
| ("border-top-width" border-width) | |||||
| ("border-width" border-width) | |||||
| ("bottom" length percentage "auto") | |||||
| ("caption-side" "top" "bottom") | |||||
| ("clear" "none" "left" "right" "both") | |||||
| ("clip" shape "auto") | |||||
| ("color" color) | |||||
| ("content" "normal" "none" string uri counter "attr()" "open-quote" | |||||
| "close-quote" "no-open-quote" "no-close-quote") | |||||
| ("counter-increment" identifier integer "none") | |||||
| ("counter-reset" identifier integer "none") | |||||
| ("cue" cue-before cue-after) | |||||
| ("cue-after" uri "none") | |||||
| ("cue-before" uri "none") | |||||
| ("cursor" uri "*" "auto" "crosshair" "default" "pointer" "move" "e-resize" | |||||
| "ne-resize" "nw-resize" "n-resize" "se-resize" "sw-resize" "s-resize" | |||||
| "w-resize" "text" "wait" "help" "progress") | |||||
| ("direction" "ltr" "rtl") | |||||
| ("display" "inline" "block" "list-item" "run-in" "inline-block" "table" | |||||
| "inline-table" "table-row-group" "table-header-group" "table-footer-group" | |||||
| "table-row" "table-column-group" "table-column" "table-cell" | |||||
| "table-caption" "none") | |||||
| ("elevation" angle "below" "level" "above" "higher" "lower") | |||||
| ("empty-cells" "show" "hide") | |||||
| ("float" "left" "right" "none") | |||||
| ("font" font-style font-variant font-weight font-size "/" line-height | |||||
| font-family "caption" "icon" "menu" "message-box" "small-caption" | |||||
| "status-bar") | |||||
| ("font-family" family-name generic-family) | |||||
| ("font-size" absolute-size relative-size length percentage) | |||||
| ("font-style" "normal" "italic" "oblique") | |||||
| ("font-variant" "normal" "small-caps") | |||||
| ("font-weight" "normal" "bold" "bolder" "lighter" "100" "200" "300" "400" | |||||
| "500" "600" "700" "800" "900") | |||||
| ("height" length percentage "auto") | |||||
| ("left" length percentage "auto") | |||||
| ("letter-spacing" "normal" length) | |||||
| ("line-height" "normal" number length percentage) | |||||
| ("list-style" list-style-type list-style-position list-style-image) | |||||
| ("list-style-image" uri "none") | |||||
| ("list-style-position" "inside" "outside") | |||||
| ("list-style-type" "disc" "circle" "square" "decimal" "decimal-leading-zero" | |||||
| "lower-roman" "upper-roman" "lower-greek" "lower-latin" "upper-latin" | |||||
| "armenian" "georgian" "lower-alpha" "upper-alpha" "none") | |||||
| ("margin" margin-width) | |||||
| ("margin-bottom" margin-width) | |||||
| ("margin-left" margin-width) | |||||
| ("margin-right" margin-width) | |||||
| ("margin-top" margin-width) | |||||
| ("max-height" length percentage "none") | |||||
| ("max-width" length percentage "none") | |||||
| ("min-height" length percentage) | |||||
| ("min-width" length percentage) | |||||
| ("orphans" integer) | |||||
| ("outline" outline-color outline-style outline-width) | |||||
| ("outline-color" color "invert") | |||||
| ("outline-style" border-style) | |||||
| ("outline-width" border-width) | |||||
| ("overflow" "visible" "hidden" "scroll" "auto") | |||||
| ("padding" padding-width) | |||||
| ("padding-bottom" padding-width) | |||||
| ("padding-left" padding-width) | |||||
| ("padding-right" padding-width) | |||||
| ("padding-top" padding-width) | |||||
| ("page-break-after" "auto" "always" "avoid" "left" "right") | |||||
| ("page-break-before" "auto" "always" "avoid" "left" "right") | |||||
| ("page-break-inside" "avoid" "auto") | |||||
| ("pause" time percentage) | |||||
| ("pause-after" time percentage) | |||||
| ("pause-before" time percentage) | |||||
| ("pitch" frequency "x-low" "low" "medium" "high" "x-high") | |||||
| ("pitch-range" number) | |||||
| ("play-during" uri "mix" "repeat" "auto" "none") | |||||
| ("position" "static" "relative" "absolute" "fixed") | |||||
| ("quotes" string string "none") | |||||
| ("richness" number) | |||||
| ("right" length percentage "auto") | |||||
| ("speak" "normal" "none" "spell-out") | |||||
| ("speak-header" "once" "always") | |||||
| ("speak-numeral" "digits" "continuous") | |||||
| ("speak-punctuation" "code" "none") | |||||
| ("speech-rate" number "x-slow" "slow" "medium" "fast" "x-fast" "faster" | |||||
| "slower") | |||||
| ("stress" number) | |||||
| ("table-layout" "auto" "fixed") | |||||
| ("text-align" "left" "right" "center" "justify") | |||||
| ("text-decoration" "none" "underline" "overline" "line-through" "blink") | |||||
| ("text-indent" length percentage) | |||||
| ("text-transform" "capitalize" "uppercase" "lowercase" "none") | |||||
| ("top" length percentage "auto") | |||||
| ("unicode-bidi" "normal" "embed" "bidi-override") | |||||
| ("vertical-align" "baseline" "sub" "super" "top" "text-top" "middle" | |||||
| "bottom" "text-bottom" percentage length) | |||||
| ("visibility" "visible" "hidden" "collapse") | |||||
| ("voice-family" specific-voice generic-voice "*" specific-voice | |||||
| generic-voice) | |||||
| ("volume" number percentage "silent" "x-soft" "soft" "medium" "loud" | |||||
| "x-loud") | |||||
| ("white-space" "normal" "pre" "nowrap" "pre-wrap" "pre-line") | |||||
| ("widows" integer) | |||||
| ("width" length percentage "auto") | |||||
| ("word-spacing" "normal" length) | |||||
| ("z-index" "auto" integer)) | |||||
| "A list of CSS properties and their possible values.") | |||||
| (defconst ac-css-value-classes | |||||
| '((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large" | |||||
| "xx-large") | |||||
| (border-style "none" "hidden" "dotted" "dashed" "solid" "double" "groove" | |||||
| "ridge" "inset" "outset") | |||||
| (color "aqua" "black" "blue" "fuchsia" "gray" "green" "lime" "maroon" "navy" | |||||
| "olive" "orange" "purple" "red" "silver" "teal" "white" "yellow" | |||||
| "rgb") | |||||
| (counter "counter") | |||||
| (family-name "Courier" "Helvetica" "Times") | |||||
| (generic-family "serif" "sans-serif" "cursive" "fantasy" "monospace") | |||||
| (generic-voice "male" "female" "child") | |||||
| (margin-width "auto") ;; length percentage | |||||
| (relative-size "larger" "smaller") | |||||
| (shape "rect") | |||||
| (uri "url")) | |||||
| "A list of CSS property value classes and their contents.") | |||||
| (defconst ac-css-pseudo-classes | |||||
| '("active" "after" "before" "first" "first-child" "first-letter" "first-line" | |||||
| "focus" "hover" "lang" "left" "link" "right" "visited") | |||||
| "Identifiers for CSS pseudo-elements and pseudo-classes.") | |||||
| (defvar ac-css-property nil | |||||
| "Current editing property.") | |||||
| (defun ac-css-prefix () | |||||
| (when (save-excursion (re-search-backward "\\_<\\(.+?\\)\\_>\\s *:[^;]*\\=" nil t)) | |||||
| (setq ac-css-property (match-string 1)) | |||||
| (or (ac-prefix-symbol) (point)))) | |||||
| (defun ac-css-property-candidates () | |||||
| (let ((list (assoc-default ac-css-property ac-css-property-alist))) | |||||
| (if list | |||||
| (cl-loop with seen | |||||
| with value | |||||
| while (setq value (pop list)) | |||||
| if (symbolp value) | |||||
| do (unless (memq value seen) | |||||
| (push value seen) | |||||
| (setq list | |||||
| (append list | |||||
| (or (assoc-default value ac-css-value-classes) | |||||
| (assoc-default (symbol-name value) ac-css-property-alist))))) | |||||
| else collect value) | |||||
| ac-css-pseudo-classes))) | |||||
| (ac-define-source css-property | |||||
| '((candidates . ac-css-property-candidates) | |||||
| (prefix . ac-css-prefix) | |||||
| (requires . 0))) | |||||
| ;; slime | |||||
| (ac-define-source slime | |||||
| '((depends slime) | |||||
| (candidates . (car (slime-simple-completions ac-prefix))) | |||||
| (symbol . "s") | |||||
| (cache))) | |||||
| ;; ghc-mod | |||||
| (ac-define-source ghc-mod | |||||
| '((depends ghc) | |||||
| (candidates . (ghc-select-completion-symbol)) | |||||
| (symbol . "s") | |||||
| (cache))) | |||||
| ;;;; Not maintained sources | |||||
| ;; ropemacs | |||||
| (defvar ac-ropemacs-loaded nil) | |||||
| (defun ac-ropemacs-require () | |||||
| (with-no-warnings | |||||
| (unless ac-ropemacs-loaded | |||||
| (pymacs-load "ropemacs" "rope-") | |||||
| (if (boundp 'ropemacs-enable-autoimport) | |||||
| (setq ropemacs-enable-autoimport t)) | |||||
| (setq ac-ropemacs-loaded t)))) | |||||
| (defun ac-ropemacs-setup () | |||||
| (ac-ropemacs-require) | |||||
| ;(setq ac-sources (append (list 'ac-source-ropemacs) ac-sources)) | |||||
| (setq ac-omni-completion-sources '(("\\." ac-source-ropemacs)))) | |||||
| (defun ac-ropemacs-initialize () | |||||
| (autoload 'pymacs-apply "pymacs") | |||||
| (autoload 'pymacs-call "pymacs") | |||||
| (autoload 'pymacs-eval "pymacs" nil t) | |||||
| (autoload 'pymacs-exec "pymacs" nil t) | |||||
| (autoload 'pymacs-load "pymacs" nil t) | |||||
| (add-hook 'python-mode-hook 'ac-ropemacs-setup) | |||||
| t) | |||||
| (defvar ac-ropemacs-completions-cache nil) | |||||
| (defvar ac-source-ropemacs | |||||
| '((init | |||||
| . (lambda () | |||||
| (setq ac-ropemacs-completions-cache | |||||
| (mapcar | |||||
| (lambda (completion) | |||||
| (concat ac-prefix completion)) | |||||
| (ignore-errors | |||||
| (rope-completions)))))) | |||||
| (candidates . ac-ropemacs-completions-cache))) | |||||
| ;; rcodetools | |||||
| (defvar ac-source-rcodetools | |||||
| '((init . (lambda () | |||||
| (require 'rcodetools) | |||||
| (condition-case x | |||||
| (save-excursion | |||||
| (rct-exec-and-eval rct-complete-command-name "--completion-emacs-icicles")) | |||||
| (error) (setq rct-method-completion-table nil)))) | |||||
| (candidates . (lambda () | |||||
| (all-completions | |||||
| ac-prefix | |||||
| (mapcar | |||||
| (lambda (completion) | |||||
| (replace-regexp-in-string "\t.*$" "" (car completion))) | |||||
| rct-method-completion-table)))))) | |||||
| ;;;; Default settings | |||||
| (defun ac-common-setup () | |||||
| ;(add-to-list 'ac-sources 'ac-source-filename) | |||||
| ) | |||||
| (defun ac-emacs-lisp-mode-setup () | |||||
| (setq ac-sources (append '(ac-source-features ac-source-functions ac-source-yasnippet ac-source-variables ac-source-symbols) ac-sources))) | |||||
| (defun ac-cc-mode-setup () | |||||
| (setq ac-sources (append '(ac-source-yasnippet ac-source-gtags) ac-sources))) | |||||
| (defun ac-ruby-mode-setup ()) | |||||
| (defun ac-css-mode-setup () | |||||
| (setq ac-sources (append '(ac-source-css-property) ac-sources))) | |||||
| ;;;###autoload | |||||
| (defun ac-config-default () | |||||
| (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers)) | |||||
| (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup) | |||||
| (add-hook 'c-mode-common-hook 'ac-cc-mode-setup) | |||||
| (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup) | |||||
| (add-hook 'css-mode-hook 'ac-css-mode-setup) | |||||
| (add-hook 'auto-complete-mode-hook 'ac-common-setup) | |||||
| (global-auto-complete-mode t)) | |||||
| (provide 'auto-complete-config) | |||||
| ;;; auto-complete-config.el ends here | |||||
| @ -0,0 +1,6 @@ | |||||
| (define-package "auto-complete" "20150408.1132" "Auto Completion for GNU Emacs" | |||||
| '((popup "0.5.0") | |||||
| (cl-lib "0.5"))) | |||||
| ;; Local Variables: | |||||
| ;; no-byte-compile: t | |||||
| ;; End: | |||||
| @ -0,0 +1,99 @@ | |||||
| alignas | |||||
| alignof | |||||
| and | |||||
| and_eq | |||||
| asm | |||||
| auto | |||||
| bitand | |||||
| bitor | |||||
| bool | |||||
| break | |||||
| case | |||||
| catch | |||||
| char | |||||
| char16_t | |||||
| char32_t | |||||
| class | |||||
| compl | |||||
| concept | |||||
| const | |||||
| const_cast | |||||
| constexpr | |||||
| continue | |||||
| decltype | |||||
| default | |||||
| define | |||||
| defined | |||||
| delete | |||||
| do | |||||
| double | |||||
| dynamic_cast | |||||
| elif | |||||
| else | |||||
| endif | |||||
| enum | |||||
| error | |||||
| explicit | |||||
| export | |||||
| extern | |||||
| false | |||||
| final | |||||
| float | |||||
| for | |||||
| friend | |||||
| goto | |||||
| if | |||||
| ifdef | |||||
| ifndef | |||||
| include | |||||
| inline | |||||
| int | |||||
| line | |||||
| long | |||||
| mutable | |||||
| namespace | |||||
| new | |||||
| noexcept | |||||
| not | |||||
| not_eq | |||||
| nullptr | |||||
| operator | |||||
| or | |||||
| or_eq | |||||
| override | |||||
| pragma | |||||
| _Pragma | |||||
| private | |||||
| protected | |||||
| public | |||||
| register | |||||
| reinterpret_cast | |||||
| requires | |||||
| return | |||||
| short | |||||
| signed | |||||
| sizeof | |||||
| static | |||||
| static_assert | |||||
| static_cast | |||||
| struct | |||||
| switch | |||||
| template | |||||
| this | |||||
| thread_local | |||||
| throw | |||||
| true | |||||
| try | |||||
| typedef | |||||
| typeid | |||||
| typename | |||||
| union | |||||
| unsigned | |||||
| using | |||||
| virtual | |||||
| void | |||||
| volatile | |||||
| wchar_t | |||||
| while | |||||
| xor | |||||
| xor_eq | |||||
| @ -0,0 +1,55 @@ | |||||
| auto | |||||
| _Alignas | |||||
| _Alignof | |||||
| _Atomic | |||||
| _Bool | |||||
| break | |||||
| case | |||||
| char | |||||
| _Complex | |||||
| const | |||||
| continue | |||||
| default | |||||
| define | |||||
| defined | |||||
| do | |||||
| double | |||||
| elif | |||||
| else | |||||
| endif | |||||
| enum | |||||
| error | |||||
| extern | |||||
| float | |||||
| for | |||||
| goto | |||||
| _Generic | |||||
| if | |||||
| ifdef | |||||
| ifndef | |||||
| _Imaginary | |||||
| include | |||||
| inline | |||||
| int | |||||
| line | |||||
| long | |||||
| _Noreturn | |||||
| pragma | |||||
| register | |||||
| restrict | |||||
| return | |||||
| short | |||||
| signed | |||||
| sizeof | |||||
| static | |||||
| struct | |||||
| switch | |||||
| _Static_assert | |||||
| typedef | |||||
| _Thread_local | |||||
| undef | |||||
| union | |||||
| unsigned | |||||
| void | |||||
| volatile | |||||
| while | |||||
| @ -0,0 +1,874 @@ | |||||
| !important | |||||
| @font-face | |||||
| @font-feature-values | |||||
| @keyframes | |||||
| ActiveBorder | |||||
| ActiveCaption | |||||
| Alpha | |||||
| AppWorkspace | |||||
| Background | |||||
| Barn | |||||
| BasicImage | |||||
| Blinds | |||||
| Blur | |||||
| ButtonFace | |||||
| ButtonHighlight | |||||
| ButtonShadow | |||||
| ButtonText | |||||
| CaptionText | |||||
| CheckerBoard | |||||
| Chroma | |||||
| Compositor | |||||
| CradientWipe | |||||
| DXImageTransform | |||||
| DropShadow | |||||
| Emboss | |||||
| Engrave | |||||
| Fade | |||||
| FlipH | |||||
| FlipV | |||||
| Glow | |||||
| Gray | |||||
| GrayText | |||||
| Highlight | |||||
| HighlightText | |||||
| Hz | |||||
| ICMFilter | |||||
| InactiveBorder | |||||
| InactiveCaption | |||||
| InactiveCaptionText | |||||
| InfoBackground | |||||
| InfoText | |||||
| Inset | |||||
| Invert | |||||
| Iris | |||||
| Light | |||||
| MaskFilter | |||||
| Matrix | |||||
| Menu | |||||
| MenuText | |||||
| Microsoft | |||||
| MotionBlur | |||||
| Pixelate | |||||
| RadialWipe | |||||
| RandomBars | |||||
| RandomDissolve | |||||
| RevealTrans | |||||
| Scrollbar | |||||
| Shadow | |||||
| Slide | |||||
| Spiral | |||||
| Stretch | |||||
| Strips | |||||
| ThreeDDarkShadow | |||||
| ThreeDFace | |||||
| ThreeDHighlight | |||||
| ThreeDLightShadow | |||||
| ThreeDShadow | |||||
| Wave | |||||
| Wheel | |||||
| Window | |||||
| WindowFrame | |||||
| WindowText | |||||
| Xray | |||||
| Zigzag | |||||
| _azimuth | |||||
| _background | |||||
| _background-position-x | |||||
| _background-position-y | |||||
| _border | |||||
| _bottom | |||||
| _caption | |||||
| _clear | |||||
| _clip | |||||
| _color | |||||
| _content | |||||
| _counter | |||||
| _cue | |||||
| _cursor | |||||
| _direction | |||||
| _display | |||||
| _elevation | |||||
| _empty | |||||
| _filter | |||||
| _filter:progid:DXImageTransform.Microsoft | |||||
| _float | |||||
| _font | |||||
| _height | |||||
| _ime | |||||
| _ime-mode | |||||
| _layout | |||||
| _layout-flow | |||||
| _layout-grid | |||||
| _layout-grid-char | |||||
| _layout-grid-line | |||||
| _layout-grid-mode | |||||
| _layout-grid-type | |||||
| _left | |||||
| _letter | |||||
| _line | |||||
| _line-break | |||||
| _list | |||||
| _margin | |||||
| _orphans | |||||
| _outline | |||||
| _overflow | |||||
| _overflow-x | |||||
| _overflow-y | |||||
| _padding | |||||
| _page | |||||
| _pause | |||||
| _pitch | |||||
| _play | |||||
| _position | |||||
| _quotes | |||||
| _richness | |||||
| _right | |||||
| _ruby | |||||
| _ruby-align | |||||
| _ruby-overhang | |||||
| _ruby-position | |||||
| _scrollbar | |||||
| _scrollbar-3dlight-color | |||||
| _scrollbar-arrow-color | |||||
| _scrollbar-base-color | |||||
| _scrollbar-darkshadow-color | |||||
| _scrollbar-face-color | |||||
| _scrollbar-highlight-color | |||||
| _scrollbar-track-color | |||||
| _speak | |||||
| _speech | |||||
| _stress | |||||
| _table | |||||
| _text | |||||
| _text-align-last | |||||
| _text-autospace | |||||
| _text-justify | |||||
| _text-kashida-space | |||||
| _text-overflow | |||||
| _text-underline-position | |||||
| _top | |||||
| _unicode | |||||
| _vertical | |||||
| _visibility | |||||
| _voice | |||||
| _volume | |||||
| _white | |||||
| _widows | |||||
| _width | |||||
| _word | |||||
| _word-break | |||||
| _word-wrap | |||||
| _writing | |||||
| _writing-mode | |||||
| _z | |||||
| _zoom | |||||
| above | |||||
| active | |||||
| adjust | |||||
| after | |||||
| aliceblue | |||||
| align | |||||
| align-content | |||||
| align-items | |||||
| align-self | |||||
| always | |||||
| animation | |||||
| animation-delay | |||||
| animation-direction | |||||
| animation-duration | |||||
| animation-fill-mode | |||||
| animation-iteration-count | |||||
| animation-name | |||||
| animation-play-state | |||||
| animation-timing-function | |||||
| antiquewhite | |||||
| aqua | |||||
| aquamarine | |||||
| armenian | |||||
| arrow | |||||
| attachment | |||||
| auto | |||||
| autospace | |||||
| avoid | |||||
| azimuth | |||||
| azure | |||||
| backface-visibility | |||||
| background | |||||
| background-attachment | |||||
| background-clip | |||||
| background-color | |||||
| background-image | |||||
| background-origin | |||||
| background-position | |||||
| background-repeat | |||||
| background-size | |||||
| bar | |||||
| base | |||||
| baseline | |||||
| before | |||||
| behind | |||||
| beige | |||||
| below | |||||
| bidi | |||||
| bidi-override | |||||
| bisque | |||||
| black | |||||
| blanchedalmond | |||||
| blink | |||||
| block | |||||
| blue | |||||
| blueviolet | |||||
| bold | |||||
| bolder | |||||
| border | |||||
| border-bottom | |||||
| border-bottom-color | |||||
| border-bottom-left-radius | |||||
| border-bottom-right-radius | |||||
| border-bottom-style | |||||
| border-bottom-width | |||||
| border-collapse | |||||
| border-color | |||||
| border-image | |||||
| border-image-outset | |||||
| border-image-repeat | |||||
| border-image-slice | |||||
| border-image-source | |||||
| border-image-width | |||||
| border-left | |||||
| border-left-color | |||||
| border-left-style | |||||
| border-left-width | |||||
| border-radius | |||||
| border-right | |||||
| border-right-color | |||||
| border-right-style | |||||
| border-right-width | |||||
| border-spacing | |||||
| border-style | |||||
| border-top | |||||
| border-top-color | |||||
| border-top-left-radius | |||||
| border-top-right-radius | |||||
| border-top-style | |||||
| border-top-width | |||||
| border-width | |||||
| both | |||||
| bottom | |||||
| box | |||||
| box-decoration-break | |||||
| box-shadow | |||||
| box-sizing | |||||
| break | |||||
| break-after | |||||
| break-before | |||||
| break-inside | |||||
| brown | |||||
| burlwood | |||||
| cadetblue | |||||
| capitalize | |||||
| caps | |||||
| caption | |||||
| caption-side | |||||
| cell | |||||
| cells | |||||
| center | |||||
| center-left | |||||
| center-right | |||||
| char | |||||
| chartreuse | |||||
| chocolate | |||||
| circle | |||||
| cjk | |||||
| cjk-ideographic | |||||
| clear | |||||
| clip | |||||
| close | |||||
| close-quote | |||||
| cm | |||||
| code | |||||
| collapse | |||||
| color | |||||
| column | |||||
| column-count | |||||
| column-fill | |||||
| column-gap | |||||
| column-rule | |||||
| column-rule-color | |||||
| column-rule-style | |||||
| column-rule-width | |||||
| column-span | |||||
| column-width | |||||
| columns | |||||
| compact | |||||
| condensed | |||||
| content | |||||
| continuous | |||||
| coral | |||||
| cornflowerblue | |||||
| cornsilk | |||||
| counter | |||||
| counter-increment | |||||
| counter-reset | |||||
| crimson | |||||
| crop | |||||
| cross | |||||
| crosshair | |||||
| cue | |||||
| cue-after | |||||
| cue-before | |||||
| cursive | |||||
| cursor | |||||
| cyan | |||||
| darkblue | |||||
| darkcyan | |||||
| darkgoldenrod | |||||
| darkgray | |||||
| darkgreen | |||||
| darkkhaki | |||||
| darkmagenta | |||||
| darkolivegreen | |||||
| darkorange | |||||
| darkorchid | |||||
| darkred | |||||
| darksalmon | |||||
| darkseagreen | |||||
| darkshadow | |||||
| darkslateblue | |||||
| darkslategray | |||||
| darkturquoise | |||||
| darkviolet | |||||
| dashed | |||||
| decimal | |||||
| decimal-leading-zero | |||||
| decoration | |||||
| deeppink | |||||
| deepskyblue | |||||
| default | |||||
| deg | |||||
| digits | |||||
| dimgray | |||||
| direction | |||||
| disc | |||||
| display | |||||
| dodgerblue | |||||
| dotted | |||||
| double | |||||
| during | |||||
| e | |||||
| e-resize | |||||
| elevation | |||||
| em | |||||
| embed | |||||
| empty | |||||
| empty-cells | |||||
| ex | |||||
| expanded | |||||
| extra | |||||
| extra-condensed | |||||
| extra-expanded | |||||
| face | |||||
| family | |||||
| fantasy | |||||
| far | |||||
| far-left | |||||
| far-right | |||||
| fast | |||||
| faster | |||||
| filter | |||||
| firebrick | |||||
| first | |||||
| first-child | |||||
| first-letter | |||||
| first-line | |||||
| fixed | |||||
| flex | |||||
| flex-basis | |||||
| flex-direction | |||||
| flex-flow | |||||
| flex-grow | |||||
| flex-shrink | |||||
| flex-wrap | |||||
| float | |||||
| floralwhite | |||||
| flow | |||||
| focus | |||||
| font | |||||
| font-family | |||||
| font-feature-setting | |||||
| font-kerning | |||||
| font-language-override | |||||
| font-size | |||||
| font-size-adjust | |||||
| font-stretch | |||||
| font-style | |||||
| font-synthesis | |||||
| font-variant | |||||
| font-variant-alternates | |||||
| font-variant-caps | |||||
| font-variant-east-asian | |||||
| font-variant-ligatures | |||||
| font-variant-numeric | |||||
| font-variant-position | |||||
| font-weight | |||||
| footer | |||||
| forestgreen | |||||
| fuchsia | |||||
| gainsboro | |||||
| georgian | |||||
| ghostwhite | |||||
| gold | |||||
| goldenrod | |||||
| gray | |||||
| greek | |||||
| green | |||||
| greenyellow | |||||
| grid | |||||
| groove | |||||
| group | |||||
| hanging-punctuation | |||||
| header | |||||
| hebrew | |||||
| height | |||||
| help | |||||
| hidden | |||||
| hide | |||||
| high | |||||
| higher | |||||
| hiragana | |||||
| hiragana-iroha | |||||
| honeydew | |||||
| hotpink | |||||
| hover | |||||
| hyphens | |||||
| icon | |||||
| ideographic | |||||
| image | |||||
| image-orientation | |||||
| image-rendering | |||||
| image-resolution | |||||
| ime-mode | |||||
| in | |||||
| increment | |||||
| indent | |||||
| index | |||||
| indianred | |||||
| indigo | |||||
| inherit | |||||
| inline | |||||
| inline-block | |||||
| inline-table | |||||
| inset | |||||
| inside | |||||
| iroha | |||||
| italic | |||||
| item | |||||
| ivory | |||||
| justify | |||||
| justify-content | |||||
| kHz | |||||
| kashida | |||||
| katakana | |||||
| katakana-iroha | |||||
| khaki | |||||
| landscape | |||||
| lang() | |||||
| large | |||||
| larger | |||||
| last | |||||
| latin | |||||
| lavender | |||||
| lavenderblush | |||||
| lawngreen | |||||
| layout | |||||
| leading | |||||
| left | |||||
| left-side | |||||
| leftwards | |||||
| lenonchiffon | |||||
| letter | |||||
| letter-spacing | |||||
| level | |||||
| lightblue | |||||
| lightcoral | |||||
| lightcyan | |||||
| lighter | |||||
| lightgoldenrodyellow | |||||
| lightgray | |||||
| lightgreen | |||||
| lightgrey | |||||
| lightpink | |||||
| lightsalmon | |||||
| lightseagreen | |||||
| lightskyblue | |||||
| lightslategray | |||||
| lightsteelblue | |||||
| lightyellow | |||||
| lime | |||||
| limegreen | |||||
| line | |||||
| line-break | |||||
| line-height | |||||
| line-through | |||||
| linen | |||||
| link | |||||
| list | |||||
| list-item | |||||
| list-style | |||||
| list-style-image | |||||
| list-style-position | |||||
| list-style-type | |||||
| loud | |||||
| low | |||||
| lower | |||||
| lower-alpha | |||||
| lower-greek | |||||
| lower-latin | |||||
| lower-roman | |||||
| lowercase | |||||
| ltr | |||||
| magenta | |||||
| margin | |||||
| margin-bottom | |||||
| margin-left | |||||
| margin-right | |||||
| margin-top | |||||
| mark | |||||
| mark-after | |||||
| mark-before | |||||
| marker | |||||
| marker-offset | |||||
| marks | |||||
| maroon | |||||
| marquee-direction | |||||
| marquee-play-count | |||||
| marquee-speed | |||||
| marquee-style | |||||
| mask | |||||
| mask-type | |||||
| max | |||||
| max-height | |||||
| max-width | |||||
| medium | |||||
| mediumaquamarine | |||||
| mediumblue | |||||
| mediumorchid | |||||
| mediumpurple | |||||
| mediumseagreen | |||||
| mediumslateblue | |||||
| mediumspringgreen | |||||
| mediumturquoise | |||||
| mediumvioletred | |||||
| menu | |||||
| message | |||||
| message-box | |||||
| middle | |||||
| midnightblue | |||||
| min | |||||
| min-height | |||||
| min-width | |||||
| mintcream | |||||
| mistyrose | |||||
| mix | |||||
| mm | |||||
| moccasin | |||||
| mode | |||||
| monospace | |||||
| move | |||||
| ms | |||||
| n | |||||
| n-resize | |||||
| naby | |||||
| narrower | |||||
| nav-down | |||||
| nav-index | |||||
| nav-left | |||||
| nav-right | |||||
| nav-up | |||||
| navajowhite | |||||
| ne | |||||
| ne-resize | |||||
| no | |||||
| no-close-quote | |||||
| no-open-quote | |||||
| no-repeat | |||||
| none | |||||
| normal | |||||
| nowrap | |||||
| number | |||||
| numeral | |||||
| nw | |||||
| nw-resize | |||||
| object-fit | |||||
| object-position | |||||
| oblique | |||||
| offset | |||||
| oldlace | |||||
| olive | |||||
| olivedrab | |||||
| once | |||||
| opacity | |||||
| open | |||||
| open-quote | |||||
| orange | |||||
| orangered | |||||
| orchid | |||||
| order | |||||
| orphans | |||||
| out | |||||
| outline | |||||
| outline-color | |||||
| outline-offset | |||||
| outline-style | |||||
| outline-width | |||||
| outset | |||||
| outside | |||||
| overflow | |||||
| overflow-wrap | |||||
| overflow-x | |||||
| overflow-y | |||||
| overhang | |||||
| overline | |||||
| override | |||||
| padding | |||||
| padding-bottom | |||||
| padding-left | |||||
| padding-right | |||||
| padding-top | |||||
| page | |||||
| page-break-after | |||||
| page-break-before | |||||
| page-break-inside | |||||
| palegoldenrod | |||||
| palegreen | |||||
| paleturquoise | |||||
| palevioletred | |||||
| papayawhip | |||||
| pause | |||||
| pause-after | |||||
| pause-before | |||||
| pc | |||||
| peachpuff | |||||
| perspective | |||||
| perspective-origin | |||||
| peru | |||||
| phonemes | |||||
| pink | |||||
| pitch | |||||
| pitch-range | |||||
| play | |||||
| play-during | |||||
| plum | |||||
| pointer | |||||
| portrait | |||||
| position | |||||
| powderblue | |||||
| pre | |||||
| pre-line | |||||
| pre-wrap | |||||
| progid | |||||
| progress | |||||
| pt | |||||
| punctuation | |||||
| purple | |||||
| px | |||||
| quote | |||||
| quotes | |||||
| rad | |||||
| range | |||||
| rate | |||||
| red | |||||
| relative | |||||
| repeat | |||||
| repeat-x | |||||
| repeat-y | |||||
| reset | |||||
| resize | |||||
| rest | |||||
| rest-after | |||||
| rest-before | |||||
| richness | |||||
| ridge | |||||
| right | |||||
| right-side | |||||
| rightwards | |||||
| roman | |||||
| rosybrown | |||||
| row | |||||
| royalblue | |||||
| rtl | |||||
| run | |||||
| run-in | |||||
| s | |||||
| s-resize | |||||
| saddlebrown | |||||
| salmon | |||||
| sandybrown | |||||
| sans-serif | |||||
| scroll | |||||
| se | |||||
| se-resize | |||||
| seagreen | |||||
| seashell | |||||
| semi | |||||
| semi-condensed | |||||
| semi-expanded | |||||
| separate | |||||
| serif | |||||
| shadow | |||||
| show | |||||
| side | |||||
| sienna | |||||
| silent | |||||
| silever | |||||
| silver | |||||
| size | |||||
| skyblue | |||||
| slateblue | |||||
| slategray | |||||
| slow | |||||
| slower | |||||
| small | |||||
| small-caps | |||||
| small-caption | |||||
| smaller | |||||
| snow | |||||
| soft | |||||
| solid | |||||
| space | |||||
| spacing | |||||
| speak | |||||
| speak-header | |||||
| speak-numeral | |||||
| speak-punctuation | |||||
| specific | |||||
| specific-voice | |||||
| speech | |||||
| speech-rate | |||||
| spell | |||||
| spell-out | |||||
| springgreen | |||||
| square | |||||
| static | |||||
| status | |||||
| status-bar | |||||
| steelblue | |||||
| stress | |||||
| stretch | |||||
| style | |||||
| sub | |||||
| super | |||||
| sw | |||||
| sw-resize | |||||
| tab-size | |||||
| table | |||||
| table-caption | |||||
| table-cell | |||||
| table-column | |||||
| table-column-group | |||||
| table-footer-group | |||||
| table-header-group | |||||
| table-layout | |||||
| table-row | |||||
| table-row-group | |||||
| tan | |||||
| teal | |||||
| text | |||||
| text-align | |||||
| text-align-last | |||||
| text-bottom | |||||
| text-combine-horizontal | |||||
| text-decoration | |||||
| text-decoration-color | |||||
| text-decoration-line | |||||
| text-decoration-style | |||||
| text-indent | |||||
| text-justify | |||||
| text-orientation | |||||
| text-overflow | |||||
| text-shadow | |||||
| text-top | |||||
| text-transform | |||||
| text-underline-position | |||||
| thick | |||||
| thin | |||||
| thistle | |||||
| through | |||||
| tomato | |||||
| top | |||||
| track | |||||
| transform | |||||
| transform-origin | |||||
| transform-style | |||||
| transition | |||||
| transition-delay | |||||
| transition-duration | |||||
| transition-property | |||||
| transition-timing-function | |||||
| transparent | |||||
| turquoise | |||||
| type | |||||
| ultra | |||||
| ultra-condensed | |||||
| ultra-expanded | |||||
| underline | |||||
| unicode | |||||
| unicode-bidi | |||||
| upper | |||||
| upper-alpha | |||||
| upper-latin | |||||
| upper-roman | |||||
| uppercase | |||||
| variant | |||||
| vertical | |||||
| vertical-align | |||||
| violet | |||||
| visibility | |||||
| visible | |||||
| visited | |||||
| voice | |||||
| voice-balance | |||||
| voice-duration | |||||
| voice-family | |||||
| voice-pitch | |||||
| voice-pitch-range | |||||
| voice-rate | |||||
| voice-stress | |||||
| voice-volume | |||||
| volume | |||||
| w | |||||
| w-resize | |||||
| wait | |||||
| weight | |||||
| wheat | |||||
| white | |||||
| white-space | |||||
| whitesmoke | |||||
| wider | |||||
| widows | |||||
| width | |||||
| word | |||||
| word-break | |||||
| word-spacing | |||||
| word-wrap | |||||
| wrap | |||||
| writing-mode | |||||
| x | |||||
| x-fast | |||||
| x-high | |||||
| x-large | |||||
| x-loud | |||||
| x-low | |||||
| x-slow | |||||
| x-small | |||||
| x-soft | |||||
| xx | |||||
| xx-large | |||||
| xx-small | |||||
| y | |||||
| yellow | |||||
| yellowgreen | |||||
| z | |||||
| z-index | |||||
| zero | |||||
| @ -0,0 +1,46 @@ | |||||
| # GNU Octave, and probably proprietary MATLAB | |||||
| # https://www.gnu.org/software/octave/doc/interpreter/Keywords.html | |||||
| __FILE__ | |||||
| __LINE__ | |||||
| break | |||||
| case | |||||
| catch | |||||
| classdef | |||||
| continue | |||||
| do | |||||
| else | |||||
| elseif | |||||
| end | |||||
| end_try_catch | |||||
| end_unwind_protect | |||||
| endclassdef | |||||
| endenumeration | |||||
| endevents | |||||
| endfor | |||||
| endfunction | |||||
| endif | |||||
| endmethods | |||||
| endparfor | |||||
| endproperties | |||||
| endswitch | |||||
| endwhile | |||||
| enumeration | |||||
| events | |||||
| for | |||||
| function | |||||
| global | |||||
| if | |||||
| methods | |||||
| otherwise | |||||
| parfor | |||||
| persistent | |||||
| properties | |||||
| return | |||||
| static | |||||
| switch | |||||
| try | |||||
| unitl | |||||
| unwind_protect | |||||
| unwind_protect_cleanup | |||||
| while | |||||
| @ -1,16 +0,0 @@ | |||||
| ;;; auto-complete-etags-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil nil ("auto-complete-etags.el") (21570 25620 | |||||
| ;;;;;; 582723 0)) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; auto-complete-etags-autoloads.el ends here | |||||
| @ -1 +0,0 @@ | |||||
| (define-package "auto-complete-etags" "0.2" "Auto-complete etags" '((auto-complete "1.3"))) | |||||
| @ -1,69 +0,0 @@ | |||||
| ;;; auto-complete-etags.el --- Auto-complete etags | |||||
| ;; Copyright 2009 Yen-Chin,Lee | |||||
| ;; | |||||
| ;; Author: Yen-Chin,Lee | |||||
| ;; Version: 0.2 | |||||
| ;; $Id: auto-complete-etags.el,v 0.2 2009/04/23 00:38:01 coldnew Exp $ | |||||
| ;; Keywords: | |||||
| ;; X-URL: not distributed yet | |||||
| ;; Package-Requires: ((auto-complete "1.3")) | |||||
| ;; Change Log: | |||||
| ;; 08-Feb-2011 Matthew L. Fidler | |||||
| ;; Changed to match ELPA standards | |||||
| ;; This program is free software; you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation; either version 2, or (at your option) | |||||
| ;; any later version. | |||||
| ;; | |||||
| ;; This program is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with this program; if not, write to the Free Software | |||||
| ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;; Put this file into your load-path and the following into your ~/.emacs: | |||||
| ;; (require 'auto-complete-etags) | |||||
| ;;; Code: | |||||
| (provide 'auto-complete-etags) | |||||
| (require 'auto-complete) | |||||
| (eval-when-compile | |||||
| (require 'cl)) | |||||
| ;;;;########################################################################## | |||||
| ;;;; User Options, Variables | |||||
| ;;;;########################################################################## | |||||
| (defface ac-etags-candidate-face | |||||
| '((t (:background "gainsboro" :foreground "deep sky blue"))) | |||||
| "Face for etags candidate") | |||||
| (defface ac-etags-selection-face | |||||
| '((t (:background "deep sky blue" :foreground "white"))) | |||||
| "Face for the etags selected candidate.") | |||||
| (defvar ac-source-etags | |||||
| '((candidates . (lambda () | |||||
| (all-completions ac-target (tags-completion-table)))) | |||||
| (candidate-face . ac-etags-candidate-face) | |||||
| (selection-face . ac-etags-selection-face) | |||||
| (requires . 3)) | |||||
| "Source for etags.") | |||||
| (provide 'auto-complete-etags) | |||||
| ;;; auto-complete-etags.el ends here | |||||
| @ -1,28 +0,0 @@ | |||||
| ;;; bison-mode-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil "bison-mode" "bison-mode.el" (21739 37356 0 | |||||
| ;;;;;; 0)) | |||||
| ;;; Generated autoloads from bison-mode.el | |||||
| (add-to-list 'auto-mode-alist '("\\.y\\'" . bison-mode)) | |||||
| (add-to-list 'auto-mode-alist '("\\.l\\'" . bison-mode)) | |||||
| (add-to-list 'auto-mode-alist '("\\.jison\\'" . jison-mode)) | |||||
| (autoload 'bison-mode "bison-mode" "\ | |||||
| Major mode for editing bison/yacc files. | |||||
| \(fn)" t nil) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; bison-mode-autoloads.el ends here | |||||
| @ -1 +0,0 @@ | |||||
| (define-package "bison-mode" "20141119.43" "Major mode for editing bison, yacc and lex files." 'nil :keywords '("bison-mode" "yacc-mode")) | |||||
| @ -1,908 +0,0 @@ | |||||
| ;;; bison-mode.el --- Major mode for editing bison, yacc and lex files. | |||||
| ;; Copyright (C) 1998 Eric Beuscher | |||||
| ;; | |||||
| ;; Author: Eric Beuscher <beuscher@eecs.tulane.edu> | |||||
| ;; Created: 2 Feb 1998 | |||||
| ;; Version: 20141119.43 | |||||
| ;; X-Original-Version: 0.2 | |||||
| ;; Keywords: bison-mode, yacc-mode | |||||
| ;; This program is free software; you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation; either version 2 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; This program is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;;; Commentary: | |||||
| ;;;; I wrote this since I saw one mode for yacc files out there roaming the | |||||
| ;;;; world. I was daunted by the fact the it was written in 1990, and Emacs | |||||
| ;;;; has evolved so much since then (this I assume based on its evolution since | |||||
| ;;;; i started using it). So I figured if i wanted one, I should make it | |||||
| ;;;; myself. Please excuse idiosyncrasies, as this was my first major mode | |||||
| ;;;; of this kind. The indentation code may be a bit weird, I am not sure, | |||||
| ;;;; it was my first go at doing Emacs indentation, so I look at how other | |||||
| ;;;; modes did it, but then basically did what I thought was right | |||||
| ;;;; I hope this is useful to other hackers, and happy Bison/Yacc hacking | |||||
| ;;;; If you have ideas/suggestions/problems with this code, I can be reached at | |||||
| ;;;; beuscher@eecs.tulane.edu | |||||
| ;;;; Eric --- Sat Mar 7 1:40:20 CDT 1998 | |||||
| ;;;; Bison Sections: | |||||
| ;;;; there are five sections to a bison file (if you include the area above the | |||||
| ;;;; C declarations section. most everything in this file either does | |||||
| ;;;; actions based on which section you are deemed to be in, or based on an | |||||
| ;;;; assumption that the function will only be called from certain sections. | |||||
| ;;;; the function `bison--section-p' is the section parser | |||||
| ;;;; Indentation: | |||||
| ;;;; indentations are done based on the section of code you are in. there is | |||||
| ;;;; a procedure `bison--within-braced-c-expression-p' that checks for being in | |||||
| ;;;; C code. if you are within c-code, indentations should occur based on | |||||
| ;;;; how you have your C indentation set up. i am pretty sure this is the | |||||
| ;;;; case. | |||||
| ;;;; there are four variables, which control bison indentation within either | |||||
| ;;;; the bison declarations section or the bison grammar section | |||||
| ;;;; `bison-rule-separator-column' | |||||
| ;;;; `bison-rule-separator-column' | |||||
| ;;;; `bison-decl-type-column' | |||||
| ;;;; `bison-decl-token-column' | |||||
| ;;;; flaw: indentation works on a per-line basis, unless within braced C sexp, | |||||
| ;;;; i should fix this someday | |||||
| ;;;; and to make matters worse, i never took out c-indent-region, so that is | |||||
| ;;;; still the state of the `indent-region-function' variable | |||||
| ;;;; Electricity: | |||||
| ;;;; by default, there are electric -colon, -pipe, -open-brace, -close-brace, | |||||
| ;;;; -semicolon, -percent, -less-than, -greater-than | |||||
| ;;;; the indentation caused by these work closely with the 4 indentation | |||||
| ;;;; variables mentioned above. | |||||
| ;;;; any of these can be turned off individually by setting the appropriate | |||||
| ;;;; `bison-electric-...' variable. or all of them can be turned off by | |||||
| ;;;; setting `bison-all-electricity-off' | |||||
| ;;;; todo: should make available a way to use C-electricity if in C sexps | |||||
| ;;; Code: | |||||
| (require 'cc-mode) | |||||
| ;;;###autoload | |||||
| (add-to-list 'auto-mode-alist '("\\.y\\'" . bison-mode)) | |||||
| ;;;###autoload | |||||
| (add-to-list 'auto-mode-alist '("\\.l\\'" . bison-mode)) | |||||
| ;;;###autoload | |||||
| (add-to-list 'auto-mode-alist '("\\.jison\\'" . jison-mode)) | |||||
| ;; *************** internal vars *************** | |||||
| (defvar bison--declarers '("%union" "%token" "%type" | |||||
| "%left" "%right" "%nonassoc") | |||||
| "commands which can declare a token or state type") | |||||
| (defvar bison--word-constituent-re "\\(\\sw\\|_\\)") | |||||
| (defvar bison--production-re | |||||
| (concat "^" bison--word-constituent-re "+:")) | |||||
| (defvar bison--pre-c-decls-section 0 | |||||
| "section before c-declarations-section, if that section exists") | |||||
| (defvar bison--c-decls-section 1 | |||||
| "section denoted by %{ and $} for c-declarations at the top of a bison file") | |||||
| (defvar bison--bison-decls-section 2 | |||||
| "section before the rules section") | |||||
| (defvar bison--grammar-rules-section 3 | |||||
| "section delimited by %%'s where productions and rules are enumerated") | |||||
| (defvar bison--c-code-section 4 | |||||
| "section after the second %% where c-code can be placed") | |||||
| (defvar bison--c-decls-section-opener "%{") | |||||
| (defvar bison--c-decls-section-closer "%}") | |||||
| (defvar bison--grammar-rules-section-delimeter "%%") | |||||
| ;; *************** user-definable vars *************** | |||||
| (defvar bison-rule-separator-column 8 | |||||
| "column for rule and production separators \"|\" and \";\"") | |||||
| (defvar bison-rule-enumeration-column 16 | |||||
| "column for beginning enumeration of a production's rules") | |||||
| (defvar bison-decl-type-column 8 | |||||
| "columnn in which tokens' and states' types should be when declared") | |||||
| (defvar bison-decl-token-column 24 | |||||
| "column in which tokens and states are listed when declared, | |||||
| as with %token, %type, ...") | |||||
| (defvar bison-all-electricity-off nil | |||||
| "non-nil means all electric keys will be disabled, | |||||
| nil means that a bison-electric-* key will be on or off based on the individual | |||||
| key's electric variable") | |||||
| ;;; i know lisp has the dual name spaces, but i find it more aesthetically | |||||
| ;;; pleasing to not take advantage of that | |||||
| (defvar bison-electric-colon-v t | |||||
| "non-nil means use an electric colon") | |||||
| (defvar bison-electric-pipe-v t | |||||
| "non-nil means use an electric pipe") | |||||
| (defvar bison-electric-open-brace-v t | |||||
| "non-nil means use an electric open-brace") | |||||
| (defvar bison-electric-close-brace-v t | |||||
| "non-nil means use an electric close-brace") | |||||
| (defvar bison-electric-semicolon-v t | |||||
| "non-nil means use an electric semicolon") | |||||
| (defvar bison-electric-percent-v t | |||||
| "non-nil means use an electric percent") | |||||
| (defvar bison-electric-less-than-v t | |||||
| "non-nil means use an electric less-than") | |||||
| (defvar bison-electric-greater-than-v t | |||||
| "non-nil means use an electric greater-than") | |||||
| (defconst bison-font-lock-keywords | |||||
| (append | |||||
| (list | |||||
| (cons (concat "^\\(" (regexp-opt bison--declarers) "\\)") | |||||
| '(1 font-lock-keyword-face)) | |||||
| ) | |||||
| c-font-lock-keywords) | |||||
| "Default expressions to highlight in Bison mode") | |||||
| ;; *************** utilities *************** | |||||
| (defun just-no-space () | |||||
| "Delete all spaces and tabs around point, leaving no spaces." | |||||
| (interactive "*") | |||||
| (skip-chars-backward " \t") | |||||
| (delete-region (point) (progn (skip-chars-forward " \t") (point))) | |||||
| t) | |||||
| (defun previous-white-space-p () | |||||
| "return t if there is whitespace between the beginning of the line and the | |||||
| current (point)" | |||||
| (save-excursion | |||||
| (let ((current-point (point))) | |||||
| (beginning-of-line) | |||||
| (if (re-search-forward "\\s " current-point t) | |||||
| t | |||||
| nil)))) | |||||
| (defun previous-non-ws-p () | |||||
| "return t if there are non-whitespace characters between beginning of line | |||||
| and \(point\)" | |||||
| (save-excursion | |||||
| (let ((current-point (point))) | |||||
| (beginning-of-line) | |||||
| (re-search-forward "[^ \t]" current-point t) | |||||
| ))) | |||||
| (defun following-non-ws-p () | |||||
| "return t if there are non-whitespace characters on the line" | |||||
| (save-excursion | |||||
| (let ((current-point (point))) | |||||
| (end-of-line) | |||||
| (re-search-backward "[^ \t]+" current-point t) | |||||
| ))) | |||||
| (defun line-of-whitespace-p () | |||||
| "return t if the line consists of nothiing but whitespace, nil otherwise" | |||||
| (save-excursion | |||||
| (let ((eol (progn (end-of-line) (point)))) | |||||
| (beginning-of-line) ;; should already be there anyway | |||||
| (not (re-search-forward "[^ \t\n]" eol t))))) | |||||
| ;; *************** bison-mode *************** | |||||
| ;;;###autoload | |||||
| (define-derived-mode bison-mode c-mode "Bison" | |||||
| "Major mode for editing bison/yacc files." | |||||
| ;; try to set the indentation correctly | |||||
| (setq c-basic-offset 4) | |||||
| (c-set-offset 'knr-argdecl-intro 0) | |||||
| ;; remove auto and hungry anything | |||||
| (c-toggle-auto-hungry-state -1) | |||||
| (c-toggle-auto-newline -1) | |||||
| (c-toggle-hungry-state -1) | |||||
| (use-local-map bison-mode-map) | |||||
| (define-key bison-mode-map ":" 'bison-electric-colon) | |||||
| (define-key bison-mode-map "|" 'bison-electric-pipe) | |||||
| (define-key bison-mode-map "{" 'bison-electric-open-brace) | |||||
| (define-key bison-mode-map "}" 'bison-electric-close-brace) | |||||
| (define-key bison-mode-map ";" 'bison-electric-semicolon) | |||||
| (define-key bison-mode-map "%" 'bison-electric-percent) | |||||
| (define-key bison-mode-map "<" 'bison-electric-less-than) | |||||
| (define-key bison-mode-map ">" 'bison-electric-greater-than) | |||||
| (define-key bison-mode-map [tab] 'bison-indent-line) | |||||
| (make-local-variable 'indent-line-function) | |||||
| (setq indent-line-function 'bison-indent-new-line) | |||||
| (make-local-variable 'comment-start) | |||||
| (make-local-variable 'comment-end) | |||||
| (setq comment-start "/*" | |||||
| comment-end "*/") | |||||
| (make-local-variable 'font-lock-keywords) | |||||
| (setq font-lock-keywords nil) | |||||
| (set (make-local-variable 'font-lock-defaults) '(bison-font-lock-keywords))) | |||||
| ;; *************** section parsers *************** | |||||
| (defun bison--section-p () | |||||
| "Return the section that user is currently in" | |||||
| (save-excursion | |||||
| (let ((bound (point))) | |||||
| (goto-char (point-min)) | |||||
| (bison--section-p-helper bound)))) | |||||
| (defun bison--section-p-helper (bound) | |||||
| (if (re-search-forward | |||||
| (concat "^" bison--c-decls-section-opener) | |||||
| bound t) | |||||
| (if (re-search-forward | |||||
| (concat "^" bison--c-decls-section-closer) | |||||
| bound t) | |||||
| (if (re-search-forward | |||||
| (concat "^" bison--grammar-rules-section-delimeter) | |||||
| bound t) | |||||
| (if (re-search-forward | |||||
| (concat "^" bison--grammar-rules-section-delimeter) | |||||
| bound t) | |||||
| bison--c-code-section | |||||
| bison--grammar-rules-section) | |||||
| bison--bison-decls-section) | |||||
| bison--c-decls-section) | |||||
| (if (re-search-forward | |||||
| (concat "^" bison--grammar-rules-section-delimeter) | |||||
| bound t) | |||||
| (if (re-search-forward | |||||
| (concat "^" bison--grammar-rules-section-delimeter) | |||||
| bound t) | |||||
| bison--c-code-section | |||||
| bison--grammar-rules-section) | |||||
| (if (re-search-forward | |||||
| (concat "^" bison--c-decls-section-opener) | |||||
| nil t) | |||||
| bison--pre-c-decls-section | |||||
| (if (re-search-forward | |||||
| (concat "^" bison--grammar-rules-section-delimeter) | |||||
| nil t) | |||||
| bison--bison-decls-section | |||||
| bison--pre-c-decls-section))))) | |||||
| ;; *************** syntax parsers *************** | |||||
| (defun bison--production-p () | |||||
| "return t if the \(point\) rests immediately after a production" | |||||
| (save-excursion | |||||
| (let ((current-point (point))) | |||||
| (beginning-of-line) | |||||
| (let ((position (re-search-forward | |||||
| bison--production-re current-point t))) | |||||
| (and position | |||||
| (not (previous-white-space-p)) | |||||
| (= position current-point)))))) | |||||
| (defun bison--find-production-opener () | |||||
| "return and goto the point of the nearest production opener above \(point\)" | |||||
| (re-search-backward bison--production-re nil t)) | |||||
| (defun bison--find-next-production () | |||||
| "return the position of the beginning of the next production, | |||||
| or nil if there isnt one" | |||||
| (save-excursion | |||||
| (if (re-search-forward bison--production-re nil t) | |||||
| (progn | |||||
| (beginning-of-line) | |||||
| (point)) | |||||
| nil))) | |||||
| (defun bison--find-grammar-end () | |||||
| "return the position of the end of the grammar rules (assuming we are within | |||||
| the grammar rules section), or nil if there isnt one" | |||||
| (save-excursion | |||||
| (if (re-search-forward | |||||
| (concat "^" bison--grammar-rules-section-delimeter) | |||||
| nil t) | |||||
| (progn | |||||
| (beginning-of-line) | |||||
| (point)) | |||||
| nil))) | |||||
| (defun bison--find-grammar-begin () | |||||
| "return the position of the beginning of the grammar rules (assuming we are | |||||
| within the grammar rules section), or nil if there isnt one" | |||||
| (save-excursion | |||||
| (if (re-search-backward | |||||
| (concat "^" bison--grammar-rules-section-delimeter) | |||||
| nil t) | |||||
| (point) | |||||
| nil))) | |||||
| (defun bison--within-started-production-p () | |||||
| "is used by bison-electric-* functions to determine actions | |||||
| return t if within a production, nil if not | |||||
| a point is within a production if there is some non whitespace text before | |||||
| either the beginnings of another production or the end of the grammar rules" | |||||
| (save-excursion | |||||
| (let ((bound (cond ((bison--find-next-production)) | |||||
| ((bison--find-grammar-end)) | |||||
| (t nil)))) | |||||
| (if bound | |||||
| (let ((sval (re-search-forward | |||||
| (concat "\\(\\s \\|" ;; whitespace or | |||||
| ;; comments | |||||
| (regexp-quote comment-start) | |||||
| "\\(.\\|\n\\)*" ;; comment body | |||||
| (regexp-quote comment-end) | |||||
| "\\)+") ;; end or | |||||
| bound t))) | |||||
| (if sval | |||||
| (not (= sval bound)) | |||||
| nil)) | |||||
| nil)))) | |||||
| (defun bison--within-some-sexp-p (starter ender) | |||||
| "return t if the \(point\) is within the sexp marked by the re's STARTER and | |||||
| ENDER" | |||||
| (save-excursion | |||||
| (let ((current-point (point))) | |||||
| (if (re-search-backward starter nil t) ;; find nearest starter | |||||
| ;; look for ender, if found, then not within sexp | |||||
| (progn | |||||
| (goto-char (match-end 0)) | |||||
| (not (re-search-forward ender current-point t))))))) | |||||
| (defun bison--within-c-comment-p () | |||||
| "return t if the point is within a c comment delimited by \"/*\" \"*/\"" | |||||
| (bison--within-some-sexp-p (regexp-quote comment-start) | |||||
| (regexp-quote comment-end))) | |||||
| (defun bison--within-string-p (&optional point) | |||||
| " | |||||
| start from the beginning of the buffer and toggle state as un-escaped \"'s are | |||||
| found." | |||||
| (let ((point (or point (point))) | |||||
| (in-p nil)) | |||||
| (save-excursion | |||||
| (goto-char (point-min)) | |||||
| (while (re-search-forward "[^\\]\"" point t) | |||||
| (setq in-p (not in-p))) | |||||
| in-p))) | |||||
| ;;; bison--within-braced-c-expression-p | |||||
| ;;; new and improved, no more recursion, does not break when literal strings | |||||
| ;;; contain un-matched braces | |||||
| (defun bison--within-braced-c-expression-p (section) | |||||
| "return t if the point is within an sexp delimited by braces \({,}\) | |||||
| " | |||||
| (save-excursion | |||||
| (bison--within-braced-c-expression-p-h section (point)))) | |||||
| (defun bison--within-braced-c-expression-p-h (section low-pt) | |||||
| " | |||||
| Notes: | |||||
| save excursion is done higher up, so i dont concern myself here. | |||||
| " | |||||
| (cond ((= section bison--pre-c-decls-section) nil) | |||||
| ((= section bison--c-decls-section) | |||||
| (let ((opener (save-excursion (search-backward "%{")))) | |||||
| (bison--within-braced-c-expression-p-h-h opener low-pt))) | |||||
| ((= section bison--bison-decls-section) | |||||
| (let ((opener (save-excursion | |||||
| (or (search-backward "%}" nil t) | |||||
| (point-min))))) | |||||
| (bison--within-braced-c-expression-p-h-h opener low-pt))) | |||||
| ((= section bison--grammar-rules-section) | |||||
| (let ((opener (save-excursion (bison--find-production-opener)))) | |||||
| (if opener | |||||
| (bison--within-braced-c-expression-p-h-h opener low-pt) | |||||
| nil))) | |||||
| ((= section bison--c-code-section) | |||||
| t))) | |||||
| (defun bison--within-braced-c-expression-p-h-h (high-pt low-pt) | |||||
| " | |||||
| Notes: | |||||
| HIGH-PT goes toward (point-min), LOW-PT goes toward (point-max) | |||||
| save excursion is done higher up, so i dont concern myself here. | |||||
| " | |||||
| (let ((pt (point))) | |||||
| (let ((success nil) (count 1) (done nil)) | |||||
| ;; loop until open brace found, that is not in comment or string literal | |||||
| (while (and (not done) | |||||
| (re-search-backward "[^%]{" high-pt t count)) ;find nearest | |||||
| ;starter | |||||
| (goto-char (match-end 0)) | |||||
| (if (or (bison--within-c-comment-p) | |||||
| (bison--within-string-p)) | |||||
| (setq count (+ count 1)) | |||||
| (progn | |||||
| (setq success t) | |||||
| (setq done t)))) | |||||
| (if success | |||||
| (let ((end-pt | |||||
| (condition-case nil | |||||
| (progn | |||||
| (backward-char) | |||||
| (forward-sexp) | |||||
| (point)) | |||||
| (error nil)))) | |||||
| (if end-pt | |||||
| (if (> end-pt low-pt) | |||||
| t ; then in braced-c-exp | |||||
| nil) | |||||
| t)) ; if no sexp close brace, then w/in | |||||
| nil)))) | |||||
| (defun bison--bison-decl-opener-p (bol eol) | |||||
| "return t if the current line is a bison declaration starter | |||||
| \(i.e. has a %type, %token, %right, ...\)" | |||||
| (save-excursion | |||||
| (goto-char bol) | |||||
| (re-search-forward | |||||
| (concat "^" (regexp-opt (copy-sequence bison--declarers))) eol t))) | |||||
| (defun bison--production-opener-p (bol eol) | |||||
| "return t if the current line is a line that introduces a new production" | |||||
| (save-excursion | |||||
| (goto-char bol) | |||||
| (re-search-forward bison--production-re eol t))) | |||||
| (defun bison--find-bison-semicolon () | |||||
| "return the position of next semicolon not within braces, nil otherwise" | |||||
| (save-excursion | |||||
| (if (search-forward ";" nil t) | |||||
| (if (not (bison--within-braced-c-expression-p (bison--section-p))) | |||||
| (point) | |||||
| (bison--find-bison-semicolon)) | |||||
| nil))) | |||||
| (defun bison--within-production-body-p (section) | |||||
| "return t if the \(point\) is within the body of a production | |||||
| this procedure will fail if it is in a production header" | |||||
| (save-excursion | |||||
| (if (= section bison--grammar-rules-section) | |||||
| (let ((current-point (point))) | |||||
| (if (re-search-backward bison--production-re nil t) | |||||
| t | |||||
| nil)) | |||||
| nil))) | |||||
| (defun bison--production-alternative-p (bol eol section) | |||||
| "return t if the current line contains a \"|\" used to designate a rule | |||||
| alternative" | |||||
| (save-excursion | |||||
| (goto-char bol) | |||||
| (if (search-forward "|" eol t) | |||||
| (not (bison--within-braced-c-expression-p section)) | |||||
| nil))) | |||||
| ;; *************** indent functions *************** | |||||
| (defun bison--handle-indent-c-sexp (section indent-column bol) | |||||
| (let* ((o-brace (re-search-backward "[^%]{" bol t)) | |||||
| ) | |||||
| (if o-brace | |||||
| (if (save-excursion | |||||
| (goto-char o-brace) | |||||
| (bison--within-braced-c-expression-p section)) | |||||
| (c-indent-line) | |||||
| (if (= (current-indentation) o-brace) ;; if o-brace is first char | |||||
| (if (not (= o-brace indent-column)) ;; but not in right spot | |||||
| (progn | |||||
| (back-to-indentation) | |||||
| (just-no-space) | |||||
| (indent-to-column indent-column)) | |||||
| ;; else all is good | |||||
| ) | |||||
| ;; else, non-ws before o-brace, leave it alone | |||||
| )) | |||||
| (c-indent-line)))) | |||||
| (defun bison-indent-new-line (&optional c-sexp) | |||||
| "Indent a fresh line of bison code | |||||
| assumes indenting a new line, i.e. at column 0 | |||||
| " | |||||
| (interactive) | |||||
| (let* ((section (bison--section-p)) | |||||
| (c-sexp (or c-sexp (bison--within-braced-c-expression-p section))) | |||||
| ) | |||||
| (cond | |||||
| (c-sexp | |||||
| (cond | |||||
| ((= section bison--grammar-rules-section) | |||||
| (c-indent-line | |||||
| (save-excursion | |||||
| (forward-line -1) | |||||
| (let ((bol (save-excursion (beginning-of-line) (point))) | |||||
| (eol (save-excursion (end-of-line) (point)))) | |||||
| (if (bison--production-opener-p bol eol) | |||||
| (list | |||||
| (cons 'defun-block-intro | |||||
| (progn | |||||
| (re-search-forward bison--production-re) ; SIGERR | |||||
| (- (re-search-forward "[^ \t]") ; SIGERR | |||||
| 1)))) | |||||
| nil))))) | |||||
| (t (c-indent-line)))) | |||||
| ((= section bison--pre-c-decls-section) | |||||
| (c-indent-line)) | |||||
| ((= section bison--bison-decls-section) | |||||
| (indent-to-column bison-decl-token-column)) | |||||
| ((= section bison--grammar-rules-section) | |||||
| (indent-to-column | |||||
| (save-excursion | |||||
| (let* ((bound (or (save-excursion (bison--find-production-opener)) | |||||
| (bison--find-grammar-begin))) | |||||
| (prev-semi (search-backward ";" bound t)) | |||||
| ) | |||||
| (if prev-semi | |||||
| (if (bison--within-braced-c-expression-p section) ; CRACK | |||||
| bison-rule-enumeration-column | |||||
| 0) | |||||
| (if (save-excursion (bison--find-production-opener)) | |||||
| bison-rule-enumeration-column | |||||
| 0)))))) | |||||
| ((= section bison--c-code-section)) ;;leave-alone | |||||
| ))) | |||||
| (defun bison-indent-line () | |||||
| "Indent a line of bison code." | |||||
| (interactive) | |||||
| (let* ((pos (- (point-max) (point))) | |||||
| (reset-pt (function (lambda () | |||||
| (if (> (- (point-max) pos) (point)) | |||||
| (goto-char (- (point-max) pos)))))) | |||||
| (bol (save-excursion (beginning-of-line) (point))) | |||||
| (eol (save-excursion (end-of-line) (point))) | |||||
| ) | |||||
| (let* ((section (bison--section-p)) | |||||
| (c-sexp (bison--within-braced-c-expression-p section)) | |||||
| (ws-line (line-of-whitespace-p)) | |||||
| ) | |||||
| (cond | |||||
| ;; if you are a line of whitespace, let indent-new-line take care of it | |||||
| (ws-line | |||||
| (bison-indent-new-line c-sexp)) | |||||
| ((= section bison--pre-c-decls-section) | |||||
| ;; leave things alone | |||||
| ) | |||||
| ((= section bison--c-decls-section) | |||||
| (if c-sexp | |||||
| (bison--handle-indent-c-sexp section 0 bol) | |||||
| (if (not (= (current-indentation) 0)) | |||||
| (progn | |||||
| (back-to-indentation) | |||||
| (just-no-space) | |||||
| (funcall reset-pt))))) | |||||
| ((= section bison--bison-decls-section) | |||||
| (let ((opener (bison--bison-decl-opener-p bol eol))) | |||||
| (cond | |||||
| (opener | |||||
| (goto-char opener) | |||||
| (skip-chars-forward " \t" eol) | |||||
| (if (looking-at "{") | |||||
| (save-excursion | |||||
| (if (following-non-ws-p) | |||||
| (progn | |||||
| (forward-char 1) | |||||
| (just-no-space) | |||||
| (newline) | |||||
| (bison-indent-new-line t)))) | |||||
| (let ((complete-type t)) | |||||
| (if (looking-at "<") | |||||
| (progn | |||||
| (setq complete-type nil) | |||||
| (if (not (= (current-column) bison-decl-type-column)) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (indent-to-column bison-decl-type-column)) | |||||
| (and (re-search-forward | |||||
| (concat "<" bison--word-constituent-re "+>") | |||||
| eol t) | |||||
| (setq complete-type t))))) | |||||
| (and complete-type | |||||
| (skip-chars-forward " \t" eol) | |||||
| (looking-at | |||||
| (concat "\\(" bison--word-constituent-re "\\|'\\)")) | |||||
| (if (not (= (current-column) bison-decl-token-column)) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (indent-to-column bison-decl-token-column)))))) | |||||
| (funcall reset-pt)) | |||||
| (c-sexp | |||||
| (bison--handle-indent-c-sexp section 0 bol)) | |||||
| (t | |||||
| (back-to-indentation) | |||||
| ;; only tab in names, leave comments alone | |||||
| (cond (;; put word-constiuents in bison-decl-token-column | |||||
| (looking-at bison--word-constituent-re) | |||||
| (if (not (= (current-column) bison-decl-token-column)) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (indent-to-column bison-decl-token-column)))) | |||||
| ;; put/keep close-brace in the 0 column | |||||
| ((looking-at "}") | |||||
| (if (not (= (current-column) 0)) | |||||
| (just-no-space))) | |||||
| ;; leave comments alone | |||||
| ((looking-at (regexp-quote comment-start)) nil) | |||||
| ;; else do nothing | |||||
| ) | |||||
| (funcall reset-pt))))) | |||||
| ((= section bison--grammar-rules-section) | |||||
| (cond | |||||
| ((bison--production-opener-p bol eol) | |||||
| (beginning-of-line) | |||||
| (re-search-forward bison--production-re);; SIGERR | |||||
| (if (following-non-ws-p) | |||||
| (if (> (current-column) bison-rule-enumeration-column) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (newline) | |||||
| (indent-to-column bison-rule-enumeration-column)) | |||||
| (save-excursion | |||||
| (re-search-forward bison--word-constituent-re);; SIGERR | |||||
| (let ((col (current-column))) | |||||
| (cond ((> col (+ 1 bison-rule-enumeration-column)) | |||||
| (forward-char -1) | |||||
| (just-no-space) | |||||
| (indent-to-column bison-rule-enumeration-column)) | |||||
| ((< col (+ 1 bison-rule-enumeration-column)) | |||||
| (forward-char -1) | |||||
| (indent-to-column | |||||
| bison-rule-enumeration-column))))))) | |||||
| (funcall reset-pt)) | |||||
| ((bison--production-alternative-p bol eol section) | |||||
| (back-to-indentation);; should put point on "|" | |||||
| (if (not (= (current-column) bison-rule-separator-column)) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (indent-to-column bison-rule-separator-column))) | |||||
| (forward-char 1) | |||||
| (if (following-non-ws-p) | |||||
| (save-excursion | |||||
| (re-search-forward bison--word-constituent-re);; SIGERR | |||||
| (let ((col (current-column))) | |||||
| (cond ((> col (+ 1 bison-rule-enumeration-column)) | |||||
| (forward-char -1) | |||||
| (just-no-space) | |||||
| (indent-to-column bison-rule-enumeration-column)) | |||||
| ((< col (+ 1 bison-rule-enumeration-column)) | |||||
| (forward-char -1) | |||||
| (indent-to-column | |||||
| bison-rule-enumeration-column)))))) | |||||
| (funcall reset-pt)) | |||||
| (c-sexp | |||||
| (bison--handle-indent-c-sexp | |||||
| section bison-rule-enumeration-column bol) | |||||
| (funcall reset-pt)) | |||||
| ((bison--within-production-body-p section) | |||||
| (back-to-indentation) | |||||
| (if (not (= (current-column) bison-rule-enumeration-column)) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (indent-to-column | |||||
| bison-rule-enumeration-column))) | |||||
| (funcall reset-pt)) | |||||
| (t | |||||
| (let ((cur-ind (current-indentation))) | |||||
| (if (eq (save-excursion (search-backward "}" bol t)) | |||||
| cur-ind) | |||||
| (if (not (= cur-ind bison-rule-enumeration-column)) | |||||
| (progn | |||||
| (back-to-indentation) | |||||
| (just-no-space) | |||||
| (indent-to-column bison-rule-enumeration-column) | |||||
| (funcall reset-pt))) | |||||
| ;; else leave alone | |||||
| ))))) | |||||
| ((= section bison--c-code-section) | |||||
| (c-indent-line)) | |||||
| )))) | |||||
| ;; *************** electric-functions *************** | |||||
| (defun bison-electric-colon (arg) | |||||
| "If the colon <:> delineates a production, | |||||
| then insert a semicolon on the next line in the BISON-RULE-SEPARATOR-COLUMN, | |||||
| put the cursor in the BISON-RULE-ENUMERATION-COLUMN for the beginning | |||||
| of the rule | |||||
| else just run self-insert-command | |||||
| A colon delineates a production by the fact that it is immediately preceded by | |||||
| a word(alphanumerics or '_''s), and there is no previous white space. | |||||
| " | |||||
| (interactive "P") | |||||
| (self-insert-command (prefix-numeric-value arg)) | |||||
| (if (and bison-electric-colon-v | |||||
| (not bison-all-electricity-off)) | |||||
| (if (and (= bison--grammar-rules-section (bison--section-p)) | |||||
| (bison--production-p) | |||||
| (not (bison--within-started-production-p))) | |||||
| (progn | |||||
| (save-excursion ; put in a closing semicolon | |||||
| (newline) | |||||
| (indent-to-column bison-rule-separator-column) | |||||
| (insert ";")) | |||||
| (save-excursion ; remove opening whitespace | |||||
| (if (re-search-backward | |||||
| "\\s " | |||||
| (save-excursion (beginning-of-line) (point)) | |||||
| t) | |||||
| (just-no-space))) | |||||
| (if (not (< (current-column) bison-rule-enumeration-column)) | |||||
| (newline)) | |||||
| (indent-to-column bison-rule-enumeration-column))))) | |||||
| (defun bison-electric-pipe (arg) | |||||
| "If the pipe <|> is used as a rule separator within a production, | |||||
| then move it into BISON-RULE-SEPARATOR-COLUMN | |||||
| indent to BISON-RULE-ENUMERATION-COLUMN on the same line | |||||
| else just run self-insert-command | |||||
| " | |||||
| (interactive "P") | |||||
| (if (and bison-electric-pipe-v | |||||
| (not bison-all-electricity-off) | |||||
| (= bison--grammar-rules-section (bison--section-p)) | |||||
| (line-of-whitespace-p) | |||||
| ) | |||||
| (progn | |||||
| (beginning-of-line) | |||||
| (just-no-space) | |||||
| (indent-to-column bison-rule-separator-column) | |||||
| (self-insert-command (prefix-numeric-value arg)) | |||||
| (indent-to-column bison-rule-enumeration-column) | |||||
| ) | |||||
| (self-insert-command (prefix-numeric-value arg)))) | |||||
| (defun bison-electric-open-brace (arg) | |||||
| "used for the opening brace of a C action definition for production rules, | |||||
| if there is only whitespace before \(point\), then put open-brace in | |||||
| bison-rule-enumeration-column" | |||||
| (interactive "P") | |||||
| (if (and bison-electric-open-brace-v | |||||
| (not bison-all-electricity-off)) | |||||
| (let ((section (bison--section-p))) | |||||
| (cond ((and (= section bison--grammar-rules-section) | |||||
| (not (bison--within-braced-c-expression-p section)) | |||||
| (not (previous-non-ws-p))) | |||||
| (if (not (= (current-column) bison-rule-enumeration-column)) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (indent-to-column bison-rule-enumeration-column)))) | |||||
| ((and (= section bison--bison-decls-section) | |||||
| (not (bison--within-braced-c-expression-p section)) | |||||
| (not (previous-non-ws-p))) | |||||
| (if (not (= (current-column) 0)) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (indent-to-column 0))))))) | |||||
| (self-insert-command (prefix-numeric-value arg))) | |||||
| (defun bison-electric-close-brace (arg) | |||||
| "If the close-brace \"}\" is used as the c-declarations section closer | |||||
| in \"%}\", then make sure the \"%}\" indents to the beginning of the line" | |||||
| (interactive "P") | |||||
| (self-insert-command (prefix-numeric-value arg)) | |||||
| (if (and bison-electric-close-brace-v | |||||
| (not bison-all-electricity-off)) | |||||
| (cond ((search-backward "%}" (- (point) 2) t) | |||||
| (if (= (bison--section-p) bison--c-decls-section) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (forward-char 2)) ; for "%}" | |||||
| (forward-char 1))) | |||||
| ))) | |||||
| (defun bison-electric-semicolon (arg) | |||||
| "if the semicolon is used to end a production, then place it in | |||||
| bison-rule-separator-column | |||||
| a semicolon is deemed to be used for ending a production if it is not found | |||||
| within braces | |||||
| this is just self-insert-command as i have yet to write the actual | |||||
| bison-electric-semicolon function yet | |||||
| " | |||||
| (interactive "P") | |||||
| (self-insert-command (prefix-numeric-value arg))) | |||||
| (defun bison-electric-percent (arg) | |||||
| "If the percent is a declarer in the bison declaration's section, | |||||
| then put it in the 0 column." | |||||
| (interactive "P") | |||||
| (if (and bison-electric-percent-v | |||||
| (not bison-all-electricity-off)) | |||||
| (let ((section (bison--section-p))) | |||||
| (if (and (= section bison--bison-decls-section) | |||||
| (not (bison--within-braced-c-expression-p section)) | |||||
| (not (previous-non-ws-p)) | |||||
| (not (= (current-column) 0))) | |||||
| (just-no-space)))) | |||||
| (self-insert-command (prefix-numeric-value arg))) | |||||
| (defun bison-electric-less-than (arg) | |||||
| "If the less-than is a type declarer opener for tokens in the bison | |||||
| declaration section, then put it in the bison-decl-type-column column." | |||||
| (interactive "P") | |||||
| (if (and bison-electric-less-than-v | |||||
| (not bison-all-electricity-off)) | |||||
| (if (and (= (bison--section-p) bison--bison-decls-section) | |||||
| (bison--bison-decl-opener-p | |||||
| (save-excursion (beginning-of-line) (point)) | |||||
| (point))) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (indent-to-column bison-decl-type-column)))) | |||||
| (self-insert-command (prefix-numeric-value arg))) | |||||
| (defun bison-electric-greater-than (arg) | |||||
| "If the greater-than is a type declarer closer for tokens in the bison | |||||
| declaration section, then indent to bison-decl-token-column." | |||||
| (interactive "P") | |||||
| (self-insert-command (prefix-numeric-value arg)) | |||||
| (if (and bison-electric-greater-than-v | |||||
| (not bison-all-electricity-off)) | |||||
| (let ((current-pt (point)) | |||||
| (bol (save-excursion (beginning-of-line) (point)))) | |||||
| (if (and (= (bison--section-p) bison--bison-decls-section) | |||||
| (bison--bison-decl-opener-p bol (point))) | |||||
| (if (search-backward "<" bol t) | |||||
| (if (re-search-forward | |||||
| (concat "<" bison--word-constituent-re "+>") | |||||
| current-pt t) | |||||
| (if (not (following-non-ws-p)) | |||||
| (progn | |||||
| (just-no-space) | |||||
| (indent-to-column bison-decl-token-column))))))))) | |||||
| (define-derived-mode jison-mode bison-mode | |||||
| "Major mode for editing jison files.") | |||||
| (provide 'bison-mode) | |||||
| (provide 'jison-mode) | |||||
| ;;; bison-mode.el ends here | |||||
| @ -1,23 +0,0 @@ | |||||
| ;;; centered-cursor-mode-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil "centered-cursor-mode" "centered-cursor-mode.el" | |||||
| ;;;;;; (21570 28355 0 0)) | |||||
| ;;; Generated autoloads from centered-cursor-mode.el | |||||
| (autoload 'centered-cursor-mode "centered-cursor-mode" "\ | |||||
| Makes the cursor stay vertically in a defined | |||||
| position (usually centered). | |||||
| \(fn &optional ARG)" t nil) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; centered-cursor-mode-autoloads.el ends here | |||||
| @ -1 +0,0 @@ | |||||
| (define-package "centered-cursor-mode" "20131121.1237" "cursor stays vertically centered" 'nil :url "http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el" :keywords '("convenience")) | |||||
| @ -1,423 +0,0 @@ | |||||
| ;;; centered-cursor-mode.el --- cursor stays vertically centered | |||||
| ;; Copyright (C) 2007 André Riemann | |||||
| ;; Author: André Riemann <andre.riemann@web.de> | |||||
| ;; Maintainer: André Riemann <andre.riemann@web.de> | |||||
| ;; Created: 2007-09-14 | |||||
| ;; Keywords: convenience | |||||
| ;; URL: http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el | |||||
| ;; Compatibility: only tested with GNU Emacs 23.0 | |||||
| ;; Version: 20131121.1237 | |||||
| ;; X-Original-Version: 0.5.2 | |||||
| ;; Last-Updated: 2009-08-31 | |||||
| ;; This file is free software; you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation; either version 2, or (at your option) | |||||
| ;; any later version. | |||||
| ;; This file is distributed in the hope that it will be useful, but | |||||
| ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| ;; General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs; see the file COPYING. If not, write to the Free | |||||
| ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||||
| ;; MA 02110-1301, USA. | |||||
| ;;; Commentary: | |||||
| ;; Makes the cursor stay vertically in a defined position (usually | |||||
| ;; centered). The vertical position can be altered, see key definition | |||||
| ;; below. | |||||
| ;; To load put that in .emacs: | |||||
| ;; (require 'centered-cursor-mode) | |||||
| ;; To activate do: | |||||
| ;; M-x centered-cursor-mode | |||||
| ;; for buffer local or | |||||
| ;; M-x global-centered-cursor-mode | |||||
| ;; for global minor mode. | |||||
| ;; Also possible: put that in .emacs | |||||
| ;; (and | |||||
| ;; (require 'centered-cursor-mode) | |||||
| ;; (global-centered-cursor-mode +1)) | |||||
| ;; to always have centered-cursor-mode on in all buffers. | |||||
| ;;; TODO: | |||||
| ;; - the code is a mess | |||||
| ;; - ccm-vpos-inverted doesn't work with ccm-vpos == 0, because first | |||||
| ;; position from top is 0 and from bottom -1 | |||||
| ;; - interactive first start isn't animated when calling global-... | |||||
| ;; because it starts the modes for each buffer and interactive-p fails | |||||
| ;; for that | |||||
| ;; - more bugs? | |||||
| ;;; Change Log: | |||||
| ;; 2009-08-31 andre-r | |||||
| ;; * replaced window-body-height with window-text-height | |||||
| ;; (partially visible lines are not counted in window-text-height) | |||||
| ;; * bug fixed in ccm-vpos-recenter | |||||
| ;; (some parentheses where wrong after the last update) | |||||
| ;; 2009-02-23 andre-r | |||||
| ;; * some simplifications | |||||
| ;; 2009-02-22 andre-r | |||||
| ;; * some tips from Drew Adams: | |||||
| ;; - new local variable coding:utf-8 | |||||
| ;; - made recenter-sequence a defvar | |||||
| ;; - added groups scrolling and convenience | |||||
| ;; - replaced mouse-4 and mouse-5 with | |||||
| ;; mouse-wheel-up-event and mouse-wheel-down-event | |||||
| ;; - added scroll-bar-toolkit-scroll to ccm-ignored-commands | |||||
| ;; - made ccm-ignored-commands customisable | |||||
| ;; * removed a bug where it didn't work with more than one window | |||||
| ;; displaying the same buffer | |||||
| ;; * added function for page up and down scrolling | |||||
| ;; (standard ones didn't work well with this mode) | |||||
| ;; * made the animation delay customisable | |||||
| ;; * made the initial vertical position customisable | |||||
| ;; * made the behaviour at the end of the file customisable | |||||
| ;; 2008-02-02 andre-r | |||||
| ;; * fixed bug that led to wrong-type-argument | |||||
| ;; when opening a new buffer | |||||
| ;; * some other minor stuff | |||||
| ;; 2007-09-24 andre-r | |||||
| ;; * added global minor mode | |||||
| ;; 2007-09-21 andre-r | |||||
| ;; * not recentering at end of buffer | |||||
| ;; * defvar animate-first-start-p | |||||
| ;; 2007-09-14 andre-r | |||||
| ;; * inital release | |||||
| ;; This file is *NOT* part of GNU Emacs. | |||||
| ;;; Code: | |||||
| (defgroup centered-cursor nil | |||||
| "Makes the cursor stay vertically in a defined position (usually centered). | |||||
| Instead the cursor the text moves around the cursor." | |||||
| :group 'scrolling | |||||
| :group 'convenience | |||||
| :link '(emacs-library-link :tag "Source Lisp File" "centered-cursor-mode.el") | |||||
| :link '(url-link "http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el")) | |||||
| (defcustom ccm-step-size 2 | |||||
| "Step size when animated recentering." | |||||
| :group 'centered-cursor | |||||
| :tag "Animation step size" | |||||
| :type 'integer) | |||||
| (defcustom ccm-step-delay 0.02 | |||||
| "Delay between animation steps. | |||||
| If you want a different animation speed." | |||||
| :group 'centered-cursor | |||||
| :tag "Animation step delay" | |||||
| :type 'number) | |||||
| (defcustom ccm-ignored-commands '(mouse-drag-region | |||||
| mouse-set-point | |||||
| widget-button-click | |||||
| scroll-bar-toolkit-scroll) | |||||
| "After these commands recentering is ignored. | |||||
| This is to prevent unintentional jumping (especially when mouse | |||||
| clicking). Following commands (except the ignored ones) will | |||||
| cause an animated recentering to give a feedback and not just | |||||
| jumping to the center." | |||||
| :group 'centered-cursor | |||||
| :tag "Ignored commands" | |||||
| :type '(repeat (symbol :tag "Command"))) | |||||
| (defcustom ccm-vpos-init '(round (window-text-height) 2) | |||||
| "This is the screen line position where the cursor initially stays." | |||||
| :group 'centered-cursor | |||||
| :tag "Vertical cursor position" | |||||
| :type '(choice (const :tag "Center" (round (window-text-height) 2)) | |||||
| (const :tag "Golden ratio" (round (* 21 (window-text-height)) 34)) | |||||
| (integer :tag "Lines from top" :value 10))) | |||||
| (make-variable-buffer-local 'ccm-vpos-init) | |||||
| (defcustom ccm-vpos-inverted 1 | |||||
| "Inverted vertical cursor position. | |||||
| Defines if the initial vertical position `ccm-vpos-init' is | |||||
| measured from the bottom instead from the top." | |||||
| :group 'centered-cursor | |||||
| :tag "Inverted cursor position" | |||||
| :type '(choice (const :tag "Inverted" -1) | |||||
| (const :tag "Not inverted" 1))) | |||||
| (make-variable-buffer-local 'ccm-vpos-inverted) | |||||
| (defcustom ccm-recenter-at-end-of-file nil | |||||
| "Recenter at the end of the file. | |||||
| If non-nil the end of the file is recentered. If nil the end of | |||||
| the file stays at the end of the window." | |||||
| :group 'centered-cursor | |||||
| :tag "Recenter at EOF" | |||||
| :type '(choice (const :tag "Don't recenter at the end of the file" nil) | |||||
| (const :tag "Recenter at the end of the file" t))) | |||||
| (make-variable-buffer-local 'ccm-recenter-end-of-file) | |||||
| (defvar ccm-vpos nil | |||||
| "This is the screen line position where the cursor stays.") | |||||
| (make-variable-buffer-local 'ccm-vpos) | |||||
| (defvar animate-first-start-p nil | |||||
| "Whether or not to animate at first start. It is set to nil, if | |||||
| centered-cursor-mode is called non-interactively.") | |||||
| (make-variable-buffer-local 'animate-first-start-p) | |||||
| (defvar recenter-sequence nil | |||||
| "Before animated recentering a list is generated first with positions | |||||
| to successively recenter to") | |||||
| (make-variable-buffer-local 'recenter-sequence) | |||||
| (defvar ccm-map | |||||
| (let ((ccm-map (make-sparse-keymap))) | |||||
| (define-key ccm-map [(control meta -)] 'ccm-vpos-up) | |||||
| (define-key ccm-map [(control meta +)] 'ccm-vpos-down) | |||||
| (define-key ccm-map [(control meta =)] 'ccm-vpos-down) | |||||
| (define-key ccm-map [(control meta ?0)] 'ccm-vpos-recenter) | |||||
| (when mouse-wheel-mode | |||||
| (mapc (lambda (key) | |||||
| (define-key ccm-map key 'ccm-mwheel-scroll)) | |||||
| (list (vector mouse-wheel-up-event) | |||||
| (vector mouse-wheel-down-event) | |||||
| (vector (list 'control mouse-wheel-up-event)) | |||||
| (vector (list 'control mouse-wheel-down-event)) | |||||
| (vector (list 'shift mouse-wheel-up-event)) | |||||
| (vector (list 'shift mouse-wheel-down-event))))) | |||||
| (define-key ccm-map [(meta v)] 'ccm-scroll-down) | |||||
| (define-key ccm-map [(control v)] 'ccm-scroll-up) | |||||
| (define-key ccm-map [prior] 'ccm-scroll-down) | |||||
| (define-key ccm-map [next] 'ccm-scroll-up) | |||||
| ccm-map) | |||||
| "Keymap used in centered-cursor-mode.") | |||||
| (defun ccm-mwheel-scroll (event) | |||||
| "Very similar to `mwheel-scroll', but does not use `scroll-down' | |||||
| and `scroll-up' but `previous-line' and `next-line', that is, the | |||||
| cursor is moved and thus the text in the window is scrolled | |||||
| due to `recenter'. | |||||
| The customizable variable `mouse-wheel-scroll-amount' is used to | |||||
| determine how much to scroll, where nil instead of a number means | |||||
| the same as in mwheel-scroll, scroll by a near full screen. | |||||
| This command exists, because mwheel-scroll caused strange | |||||
| behaviour with automatic recentering." | |||||
| ;; (interactive (list last-input-event)) | |||||
| (interactive "e") | |||||
| (let* ((mods (delq 'click (delq 'double (delq 'triple (event-modifiers event))))) | |||||
| (amt (assoc mods mouse-wheel-scroll-amount))) | |||||
| ;;(message "%S" mods) | |||||
| (if amt | |||||
| (setq amt (or (cdr amt) | |||||
| (- (window-text-height) | |||||
| next-screen-context-lines))) | |||||
| (let ((list-elt mouse-wheel-scroll-amount)) | |||||
| (while (consp (setq amt (pop list-elt)))))) | |||||
| (if mouse-wheel-follow-mouse | |||||
| (select-window (posn-window (event-start event)))) | |||||
| (let ((button (mwheel-event-button event))) | |||||
| (cond | |||||
| ((eq button mouse-wheel-down-event) | |||||
| (forward-line (- amt))) | |||||
| ;;(princ amt)) | |||||
| ((eq button mouse-wheel-up-event) | |||||
| (forward-line amt)) | |||||
| ;;(princ amt)) | |||||
| (t (error "Bad binding in ccm-mwheel-scroll")))))) | |||||
| (defun ccm-scroll-down (&optional arg) | |||||
| "Replaces `scroll-down' because with scroll-down | |||||
| `centered-cursor-mode' sometimes doesn't reach the top of the | |||||
| buffer. This version actually moves the cursor with | |||||
| `previous-line'. Since with centered-cursor-mode the cursor is in | |||||
| a fixed position the movement appears as page up." | |||||
| (interactive "P") | |||||
| (let ((amt (or arg (- (window-text-height) | |||||
| next-screen-context-lines)))) | |||||
| (forward-line (- amt)))) | |||||
| (defun ccm-scroll-up (&optional arg) | |||||
| "Replaces `scroll-up' to be consistent with `ccm-scroll-down'. | |||||
| This version actually moves the cursor with `previous-line'. | |||||
| Since with centered-cursor-mode the cursor is in a fixed position | |||||
| the movement appears as page up." | |||||
| (interactive "P") | |||||
| (let ((amt (or arg (- (window-text-height) | |||||
| next-screen-context-lines)))) | |||||
| (forward-line amt))) | |||||
| (defun ccm-vpos-down (arg) | |||||
| "Adjust the value of the screen line (where the cursor stays) by arg. | |||||
| Negative values for arg are possible. Just the variable ccm-vpos | |||||
| is set." | |||||
| (interactive "p") | |||||
| (or arg (setq arg 1)) | |||||
| (let ((new-pos (if (< ccm-vpos 0) | |||||
| (- ccm-vpos arg) | |||||
| (+ ccm-vpos arg))) | |||||
| ;; see pos-visible-in-window-p | |||||
| (vpos-max (if (< ccm-vpos 0) | |||||
| -1 | |||||
| (- (window-text-height) 1))) | |||||
| (vpos-min (if (< ccm-vpos 0) | |||||
| (- (window-text-height)) | |||||
| 0))) | |||||
| (setq ccm-vpos | |||||
| (cond | |||||
| ((< new-pos vpos-min) | |||||
| vpos-min) | |||||
| ((> new-pos vpos-max) | |||||
| vpos-max) | |||||
| (t | |||||
| new-pos))))) | |||||
| (defun ccm-vpos-up (arg) | |||||
| "See `ccm-vpos-down'." | |||||
| (interactive "p") | |||||
| (or arg (setq arg 1)) | |||||
| (ccm-vpos-down (- arg))) | |||||
| (defun ccm-vpos-recenter () | |||||
| "Set the value of the screen line (where the cursor stays) in | |||||
| the center. Just the variable ccm-vpos is set." | |||||
| (interactive) | |||||
| (if (equal (current-buffer) | |||||
| (window-buffer (selected-window))) | |||||
| (setq ccm-vpos (* (eval ccm-vpos-init) | |||||
| ccm-vpos-inverted)))) | |||||
| (defun ccm-position-cursor () | |||||
| "Do the actual recentering at the position `ccm-vpos'." | |||||
| (unless (member this-command ccm-ignored-commands) | |||||
| (unless ccm-vpos | |||||
| (ccm-vpos-recenter)) | |||||
| (unless (minibufferp (current-buffer)) | |||||
| (if (equal (current-buffer) | |||||
| (window-buffer (selected-window))) | |||||
| (let* ((current-line | |||||
| (if (< ccm-vpos 0) | |||||
| ;; one-based, from bottom, negative | |||||
| (- (count-lines (point) | |||||
| ;; window-end is sometimes < 0 | |||||
| ;; when opening a help buffer | |||||
| (if (> (window-end) 0) | |||||
| (window-end) | |||||
| 1))) | |||||
| ;; zero-based, from top, positive | |||||
| (+ (count-lines (window-start) (point)) | |||||
| ;; count-lines returns different value in column 0 | |||||
| (if (= (current-column) 0) 0 -1)))) | |||||
| (diff (- ccm-vpos current-line)) | |||||
| (step-size ccm-step-size) | |||||
| (step-delay ccm-step-delay) | |||||
| (vpos-inverted ccm-vpos-inverted) | |||||
| (recenter-at-end-of-file ccm-recenter-at-end-of-file)) | |||||
| (let* ((bottom-vpos (if (< ccm-vpos 0) | |||||
| (- ccm-vpos) | |||||
| (- (window-text-height) ccm-vpos))) | |||||
| (correction (save-excursion | |||||
| (if (or (= (point) (point-max)) | |||||
| (progn | |||||
| (goto-char (point-max)) | |||||
| (zerop (current-column)))) | |||||
| 1 0))) | |||||
| ;; lines from point to end of buffer | |||||
| (bottom-lines (+ (count-lines (point) (point-max)) | |||||
| correction))) | |||||
| ;; only animate if the point was moved rather far away | |||||
| ;; before by a mouseclick (see ccm-ignored-commands) | |||||
| ;; or if minor mode is just entered interactively | |||||
| (if (not (and (> (abs diff) 4) | |||||
| (or (member last-command ccm-ignored-commands) | |||||
| animate-first-start-p))) | |||||
| (recenter (if (and (< bottom-lines bottom-vpos) | |||||
| (not recenter-at-end-of-file)) | |||||
| ;; if near the bottom, recenter in the | |||||
| ;; negative screen line that equals the | |||||
| ;; bottom buffer line, i.e. if we are in | |||||
| ;; the second last line (-2) of the | |||||
| ;; buffer, the cursor will be recentered | |||||
| ;; in -2 | |||||
| (- bottom-lines) | |||||
| ccm-vpos)) | |||||
| (setq animate-first-start-p nil) | |||||
| ;; first build a list with positions to successively recenter to | |||||
| (setq recenter-sequence | |||||
| ;; reverse: because we build the list not FROM -> TO but | |||||
| ;; TO -> FROM because if step size in number-sequence is | |||||
| ;; bigger than one, TO might not included, that means the | |||||
| ;; ccm-vpos would not be reached | |||||
| ;; cdr: don't recenter the current-line | |||||
| (if (and (< bottom-lines bottom-vpos) | |||||
| (not recenter-at-end-of-file)) | |||||
| ;; this one is for animation near the bottom | |||||
| (cdr (reverse (number-sequence | |||||
| (- bottom-lines) | |||||
| (if (< ccm-vpos 0) | |||||
| current-line | |||||
| (- (- (window-text-height) current-line))) | |||||
| (* (/ diff (abs diff)) (- step-size))))) | |||||
| (cdr (reverse (number-sequence | |||||
| ccm-vpos | |||||
| current-line | |||||
| (* (/ diff (abs diff)) (- step-size))))))) | |||||
| ;; (message "%d %d %d (%d): %S" current-line ccm-vpos bottom-lines diff recenter-sequence) | |||||
| (while recenter-sequence | |||||
| ;; actual animation | |||||
| (recenter (pop recenter-sequence)) | |||||
| (if (car recenter-sequence) (sit-for step-delay t)))))))))) | |||||
| (defun ccm-first-start (animate) | |||||
| "Called from centered-cursor-mode. Animate at first start, if | |||||
| centered-cursor-mode is called interactively." | |||||
| (let ((animate-first-start-p animate)) | |||||
| (ccm-vpos-recenter) | |||||
| (ccm-position-cursor))) | |||||
| ;;(defalias 'ccm 'centered-cursor-mode) | |||||
| ;;;###autoload | |||||
| (define-minor-mode centered-cursor-mode | |||||
| "Makes the cursor stay vertically in a defined | |||||
| position (usually centered)." | |||||
| :init-value nil | |||||
| ;; :lighter nil | |||||
| :lighter " ¢" | |||||
| :keymap ccm-map | |||||
| (cond | |||||
| (centered-cursor-mode | |||||
| (ccm-first-start (interactive-p)) | |||||
| (add-hook 'post-command-hook 'ccm-position-cursor t t) | |||||
| (add-hook 'window-configuration-change-hook 'ccm-vpos-recenter t t)) | |||||
| (t | |||||
| (remove-hook 'post-command-hook 'ccm-position-cursor t) | |||||
| (remove-hook 'window-configuration-change-hook 'ccm-vpos-recenter t)))) | |||||
| (define-global-minor-mode global-centered-cursor-mode centered-cursor-mode | |||||
| centered-cursor-mode) | |||||
| (provide 'centered-cursor-mode) | |||||
| ;;; Help: | |||||
| ;; (info "(elisp)Defining Minor Modes") | |||||
| ;; (info "(elisp)Screen Lines") | |||||
| ;; (info "(elisp)Hooks") | |||||
| ;; (info "(elisp)Customization") | |||||
| ;; (find-function 'mwheel-scroll) | |||||
| ;; Local Variables: | |||||
| ;; coding: utf-8 | |||||
| ;; End: | |||||
| ;;; centered-cursor-mode.el ends here | |||||
| @ -0,0 +1,23 @@ | |||||
| ;;; centered-cursor-mode-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil "centered-cursor-mode" "centered-cursor-mode.el" | |||||
| ;;;;;; (21837 24217 0 0)) | |||||
| ;;; Generated autoloads from centered-cursor-mode.el | |||||
| (autoload 'centered-cursor-mode "centered-cursor-mode" "\ | |||||
| Makes the cursor stay vertically in a defined | |||||
| position (usually centered). | |||||
| \(fn &optional ARG)" t nil) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; centered-cursor-mode-autoloads.el ends here | |||||
| @ -0,0 +1 @@ | |||||
| (define-package "centered-cursor-mode" "20150420.1942" "cursor stays vertically centered" 'nil :url "http://www.emacswiki.org/emacs/centered-cursor-mode.el" :keywords '("convenience")) | |||||
| @ -0,0 +1,430 @@ | |||||
| ;;; centered-cursor-mode.el --- cursor stays vertically centered | |||||
| ;; Copyright (C) 2007 André Riemann | |||||
| ;; Author: André Riemann <andre.riemann@web.de> | |||||
| ;; Maintainer: André Riemann <andre.riemann@web.de> | |||||
| ;; Created: 2007-09-14 | |||||
| ;; Keywords: convenience | |||||
| ;; Package-Version: 20150420.1942 | |||||
| ;; URL: http://www.emacswiki.org/emacs/centered-cursor-mode.el | |||||
| ;; Compatibility: tested with GNU Emacs 23.0, 24 | |||||
| ;; Version: 0.5.4 | |||||
| ;; Last-Updated: 2015-04-20 | |||||
| ;; This file is free software; you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation; either version 2, or (at your option) | |||||
| ;; any later version. | |||||
| ;; This file is distributed in the hope that it will be useful, but | |||||
| ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| ;; General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs; see the file COPYING. If not, write to the Free | |||||
| ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||||
| ;; MA 02110-1301, USA. | |||||
| ;;; Commentary: | |||||
| ;; Makes the cursor stay vertically in a defined position (usually | |||||
| ;; centered). The vertical position can be altered, see key definition | |||||
| ;; below. | |||||
| ;; To load put that in .emacs: | |||||
| ;; (require 'centered-cursor-mode) | |||||
| ;; To activate do: | |||||
| ;; M-x centered-cursor-mode | |||||
| ;; for buffer local or | |||||
| ;; M-x global-centered-cursor-mode | |||||
| ;; for global minor mode. | |||||
| ;; Also possible: put that in .emacs | |||||
| ;; (and | |||||
| ;; (require 'centered-cursor-mode) | |||||
| ;; (global-centered-cursor-mode +1)) | |||||
| ;; to always have centered-cursor-mode on in all buffers. | |||||
| ;;; TODO: | |||||
| ;; - the code is a mess | |||||
| ;; - ccm-vpos-inverted doesn't work with ccm-vpos == 0, because first | |||||
| ;; position from top is 0 and from bottom -1 | |||||
| ;; - interactive first start isn't animated when calling global-... | |||||
| ;; because it starts the modes for each buffer and interactive-p fails | |||||
| ;; for that | |||||
| ;; - more bugs? | |||||
| ;;; Change Log: | |||||
| ;; 2015-04-20 andre-r | |||||
| ;; * corrected URL in header | |||||
| ;; 2015-03-01 andre-r | |||||
| ;; * fixed bug where Emacs without X support (emacs-nox) didn't find mouse-wheel-mode | |||||
| ;; 2009-08-31 andre-r | |||||
| ;; * replaced window-body-height with window-text-height | |||||
| ;; (partially visible lines are not counted in window-text-height) | |||||
| ;; * bug fixed in ccm-vpos-recenter | |||||
| ;; (some parentheses where wrong after the last update) | |||||
| ;; 2009-02-23 andre-r | |||||
| ;; * some simplifications | |||||
| ;; 2009-02-22 andre-r | |||||
| ;; * some tips from Drew Adams: | |||||
| ;; - new local variable coding:utf-8 | |||||
| ;; - made recenter-sequence a defvar | |||||
| ;; - added groups scrolling and convenience | |||||
| ;; - replaced mouse-4 and mouse-5 with | |||||
| ;; mouse-wheel-up-event and mouse-wheel-down-event | |||||
| ;; - added scroll-bar-toolkit-scroll to ccm-ignored-commands | |||||
| ;; - made ccm-ignored-commands customisable | |||||
| ;; * removed a bug where it didn't work with more than one window | |||||
| ;; displaying the same buffer | |||||
| ;; * added function for page up and down scrolling | |||||
| ;; (standard ones didn't work well with this mode) | |||||
| ;; * made the animation delay customisable | |||||
| ;; * made the initial vertical position customisable | |||||
| ;; * made the behaviour at the end of the file customisable | |||||
| ;; 2008-02-02 andre-r | |||||
| ;; * fixed bug that led to wrong-type-argument | |||||
| ;; when opening a new buffer | |||||
| ;; * some other minor stuff | |||||
| ;; 2007-09-24 andre-r | |||||
| ;; * added global minor mode | |||||
| ;; 2007-09-21 andre-r | |||||
| ;; * not recentering at end of buffer | |||||
| ;; * defvar animate-first-start-p | |||||
| ;; 2007-09-14 andre-r | |||||
| ;; * inital release | |||||
| ;; This file is *NOT* part of GNU Emacs. | |||||
| ;;; Code: | |||||
| (require 'mouse-wheel-mode nil 'noerror) | |||||
| (defgroup centered-cursor nil | |||||
| "Makes the cursor stay vertically in a defined position (usually centered). | |||||
| Instead the cursor the text moves around the cursor." | |||||
| :group 'scrolling | |||||
| :group 'convenience | |||||
| :link '(emacs-library-link :tag "Source Lisp File" "centered-cursor-mode.el") | |||||
| :link '(url-link "http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el")) | |||||
| (defcustom ccm-step-size 2 | |||||
| "Step size when animated recentering." | |||||
| :group 'centered-cursor | |||||
| :tag "Animation step size" | |||||
| :type 'integer) | |||||
| (defcustom ccm-step-delay 0.02 | |||||
| "Delay between animation steps. | |||||
| If you want a different animation speed." | |||||
| :group 'centered-cursor | |||||
| :tag "Animation step delay" | |||||
| :type 'number) | |||||
| (defcustom ccm-ignored-commands '(mouse-drag-region | |||||
| mouse-set-point | |||||
| widget-button-click | |||||
| scroll-bar-toolkit-scroll) | |||||
| "After these commands recentering is ignored. | |||||
| This is to prevent unintentional jumping (especially when mouse | |||||
| clicking). Following commands (except the ignored ones) will | |||||
| cause an animated recentering to give a feedback and not just | |||||
| jumping to the center." | |||||
| :group 'centered-cursor | |||||
| :tag "Ignored commands" | |||||
| :type '(repeat (symbol :tag "Command"))) | |||||
| (defcustom ccm-vpos-init '(round (window-text-height) 2) | |||||
| "This is the screen line position where the cursor initially stays." | |||||
| :group 'centered-cursor | |||||
| :tag "Vertical cursor position" | |||||
| :type '(choice (const :tag "Center" (round (window-text-height) 2)) | |||||
| (const :tag "Golden ratio" (round (* 21 (window-text-height)) 34)) | |||||
| (integer :tag "Lines from top" :value 10))) | |||||
| (make-variable-buffer-local 'ccm-vpos-init) | |||||
| (defcustom ccm-vpos-inverted 1 | |||||
| "Inverted vertical cursor position. | |||||
| Defines if the initial vertical position `ccm-vpos-init' is | |||||
| measured from the bottom instead from the top." | |||||
| :group 'centered-cursor | |||||
| :tag "Inverted cursor position" | |||||
| :type '(choice (const :tag "Inverted" -1) | |||||
| (const :tag "Not inverted" 1))) | |||||
| (make-variable-buffer-local 'ccm-vpos-inverted) | |||||
| (defcustom ccm-recenter-at-end-of-file nil | |||||
| "Recenter at the end of the file. | |||||
| If non-nil the end of the file is recentered. If nil the end of | |||||
| the file stays at the end of the window." | |||||
| :group 'centered-cursor | |||||
| :tag "Recenter at EOF" | |||||
| :type '(choice (const :tag "Don't recenter at the end of the file" nil) | |||||
| (const :tag "Recenter at the end of the file" t))) | |||||
| (make-variable-buffer-local 'ccm-recenter-end-of-file) | |||||
| (defvar ccm-vpos nil | |||||
| "This is the screen line position where the cursor stays.") | |||||
| (make-variable-buffer-local 'ccm-vpos) | |||||
| (defvar animate-first-start-p nil | |||||
| "Whether or not to animate at first start. It is set to nil, if | |||||
| centered-cursor-mode is called non-interactively.") | |||||
| (make-variable-buffer-local 'animate-first-start-p) | |||||
| (defvar recenter-sequence nil | |||||
| "Before animated recentering a list is generated first with positions | |||||
| to successively recenter to") | |||||
| (make-variable-buffer-local 'recenter-sequence) | |||||
| (defvar ccm-map | |||||
| (let ((ccm-map (make-sparse-keymap))) | |||||
| (define-key ccm-map [(control meta -)] 'ccm-vpos-up) | |||||
| (define-key ccm-map [(control meta +)] 'ccm-vpos-down) | |||||
| (define-key ccm-map [(control meta =)] 'ccm-vpos-down) | |||||
| (define-key ccm-map [(control meta ?0)] 'ccm-vpos-recenter) | |||||
| (when (and (boundp 'mouse-wheel-mode) mouse-wheel-mode) | |||||
| (mapc (lambda (key) | |||||
| (define-key ccm-map key 'ccm-mwheel-scroll)) | |||||
| (list (vector mouse-wheel-up-event) | |||||
| (vector mouse-wheel-down-event) | |||||
| (vector (list 'control mouse-wheel-up-event)) | |||||
| (vector (list 'control mouse-wheel-down-event)) | |||||
| (vector (list 'shift mouse-wheel-up-event)) | |||||
| (vector (list 'shift mouse-wheel-down-event))))) | |||||
| (define-key ccm-map [(meta v)] 'ccm-scroll-down) | |||||
| (define-key ccm-map [(control v)] 'ccm-scroll-up) | |||||
| (define-key ccm-map [prior] 'ccm-scroll-down) | |||||
| (define-key ccm-map [next] 'ccm-scroll-up) | |||||
| ccm-map) | |||||
| "Keymap used in centered-cursor-mode.") | |||||
| (defun ccm-mwheel-scroll (event) | |||||
| "Very similar to `mwheel-scroll', but does not use `scroll-down' | |||||
| and `scroll-up' but `previous-line' and `next-line', that is, the | |||||
| cursor is moved and thus the text in the window is scrolled | |||||
| due to `recenter'. | |||||
| The customizable variable `mouse-wheel-scroll-amount' is used to | |||||
| determine how much to scroll, where nil instead of a number means | |||||
| the same as in mwheel-scroll, scroll by a near full screen. | |||||
| This command exists, because mwheel-scroll caused strange | |||||
| behaviour with automatic recentering." | |||||
| ;; (interactive (list last-input-event)) | |||||
| (interactive "e") | |||||
| (let* ((mods (delq 'click (delq 'double (delq 'triple (event-modifiers event))))) | |||||
| (amt (assoc mods mouse-wheel-scroll-amount))) | |||||
| ;;(message "%S" mods) | |||||
| (if amt | |||||
| (setq amt (or (cdr amt) | |||||
| (- (window-text-height) | |||||
| next-screen-context-lines))) | |||||
| (let ((list-elt mouse-wheel-scroll-amount)) | |||||
| (while (consp (setq amt (pop list-elt)))))) | |||||
| (if mouse-wheel-follow-mouse | |||||
| (select-window (posn-window (event-start event)))) | |||||
| (let ((button (mwheel-event-button event))) | |||||
| (cond | |||||
| ((eq button mouse-wheel-down-event) | |||||
| (forward-line (- amt))) | |||||
| ;;(princ amt)) | |||||
| ((eq button mouse-wheel-up-event) | |||||
| (forward-line amt)) | |||||
| ;;(princ amt)) | |||||
| (t (error "Bad binding in ccm-mwheel-scroll")))))) | |||||
| (defun ccm-scroll-down (&optional arg) | |||||
| "Replaces `scroll-down' because with scroll-down | |||||
| `centered-cursor-mode' sometimes doesn't reach the top of the | |||||
| buffer. This version actually moves the cursor with | |||||
| `previous-line'. Since with centered-cursor-mode the cursor is in | |||||
| a fixed position the movement appears as page up." | |||||
| (interactive "P") | |||||
| (let ((amt (or arg (- (window-text-height) | |||||
| next-screen-context-lines)))) | |||||
| (forward-line (- amt)))) | |||||
| (defun ccm-scroll-up (&optional arg) | |||||
| "Replaces `scroll-up' to be consistent with `ccm-scroll-down'. | |||||
| This version actually moves the cursor with `previous-line'. | |||||
| Since with centered-cursor-mode the cursor is in a fixed position | |||||
| the movement appears as page up." | |||||
| (interactive "P") | |||||
| (let ((amt (or arg (- (window-text-height) | |||||
| next-screen-context-lines)))) | |||||
| (forward-line amt))) | |||||
| (defun ccm-vpos-down (arg) | |||||
| "Adjust the value of the screen line (where the cursor stays) by arg. | |||||
| Negative values for arg are possible. Just the variable ccm-vpos | |||||
| is set." | |||||
| (interactive "p") | |||||
| (or arg (setq arg 1)) | |||||
| (let ((new-pos (if (< ccm-vpos 0) | |||||
| (- ccm-vpos arg) | |||||
| (+ ccm-vpos arg))) | |||||
| ;; see pos-visible-in-window-p | |||||
| (vpos-max (if (< ccm-vpos 0) | |||||
| -1 | |||||
| (- (window-text-height) 1))) | |||||
| (vpos-min (if (< ccm-vpos 0) | |||||
| (- (window-text-height)) | |||||
| 0))) | |||||
| (setq ccm-vpos | |||||
| (cond | |||||
| ((< new-pos vpos-min) | |||||
| vpos-min) | |||||
| ((> new-pos vpos-max) | |||||
| vpos-max) | |||||
| (t | |||||
| new-pos))))) | |||||
| (defun ccm-vpos-up (arg) | |||||
| "See `ccm-vpos-down'." | |||||
| (interactive "p") | |||||
| (or arg (setq arg 1)) | |||||
| (ccm-vpos-down (- arg))) | |||||
| (defun ccm-vpos-recenter () | |||||
| "Set the value of the screen line (where the cursor stays) in | |||||
| the center. Just the variable ccm-vpos is set." | |||||
| (interactive) | |||||
| (if (equal (current-buffer) | |||||
| (window-buffer (selected-window))) | |||||
| (setq ccm-vpos (* (eval ccm-vpos-init) | |||||
| ccm-vpos-inverted)))) | |||||
| (defun ccm-position-cursor () | |||||
| "Do the actual recentering at the position `ccm-vpos'." | |||||
| (unless (member this-command ccm-ignored-commands) | |||||
| (unless ccm-vpos | |||||
| (ccm-vpos-recenter)) | |||||
| (unless (minibufferp (current-buffer)) | |||||
| (if (equal (current-buffer) | |||||
| (window-buffer (selected-window))) | |||||
| (let* ((current-line | |||||
| (if (< ccm-vpos 0) | |||||
| ;; one-based, from bottom, negative | |||||
| (- (count-lines (point) | |||||
| ;; window-end is sometimes < 0 | |||||
| ;; when opening a help buffer | |||||
| (if (> (window-end) 0) | |||||
| (window-end) | |||||
| 1))) | |||||
| ;; zero-based, from top, positive | |||||
| (+ (count-lines (window-start) (point)) | |||||
| ;; count-lines returns different value in column 0 | |||||
| (if (= (current-column) 0) 0 -1)))) | |||||
| (diff (- ccm-vpos current-line)) | |||||
| (step-size ccm-step-size) | |||||
| (step-delay ccm-step-delay) | |||||
| (vpos-inverted ccm-vpos-inverted) | |||||
| (recenter-at-end-of-file ccm-recenter-at-end-of-file)) | |||||
| (let* ((bottom-vpos (if (< ccm-vpos 0) | |||||
| (- ccm-vpos) | |||||
| (- (window-text-height) ccm-vpos))) | |||||
| (correction (save-excursion | |||||
| (if (or (= (point) (point-max)) | |||||
| (progn | |||||
| (goto-char (point-max)) | |||||
| (zerop (current-column)))) | |||||
| 1 0))) | |||||
| ;; lines from point to end of buffer | |||||
| (bottom-lines (+ (count-lines (point) (point-max)) | |||||
| correction))) | |||||
| ;; only animate if the point was moved rather far away | |||||
| ;; before by a mouseclick (see ccm-ignored-commands) | |||||
| ;; or if minor mode is just entered interactively | |||||
| (if (not (and (> (abs diff) 4) | |||||
| (or (member last-command ccm-ignored-commands) | |||||
| animate-first-start-p))) | |||||
| (recenter (if (and (< bottom-lines bottom-vpos) | |||||
| (not recenter-at-end-of-file)) | |||||
| ;; if near the bottom, recenter in the | |||||
| ;; negative screen line that equals the | |||||
| ;; bottom buffer line, i.e. if we are in | |||||
| ;; the second last line (-2) of the | |||||
| ;; buffer, the cursor will be recentered | |||||
| ;; in -2 | |||||
| (- bottom-lines) | |||||
| ccm-vpos)) | |||||
| (setq animate-first-start-p nil) | |||||
| ;; first build a list with positions to successively recenter to | |||||
| (setq recenter-sequence | |||||
| ;; reverse: because we build the list not FROM -> TO but | |||||
| ;; TO -> FROM because if step size in number-sequence is | |||||
| ;; bigger than one, TO might not included, that means the | |||||
| ;; ccm-vpos would not be reached | |||||
| ;; cdr: don't recenter the current-line | |||||
| (if (and (< bottom-lines bottom-vpos) | |||||
| (not recenter-at-end-of-file)) | |||||
| ;; this one is for animation near the bottom | |||||
| (cdr (reverse (number-sequence | |||||
| (- bottom-lines) | |||||
| (if (< ccm-vpos 0) | |||||
| current-line | |||||
| (- (- (window-text-height) current-line))) | |||||
| (* (/ diff (abs diff)) (- step-size))))) | |||||
| (cdr (reverse (number-sequence | |||||
| ccm-vpos | |||||
| current-line | |||||
| (* (/ diff (abs diff)) (- step-size))))))) | |||||
| ;; (message "%d %d %d (%d): %S" current-line ccm-vpos bottom-lines diff recenter-sequence) | |||||
| (while recenter-sequence | |||||
| ;; actual animation | |||||
| (recenter (pop recenter-sequence)) | |||||
| (if (car recenter-sequence) (sit-for step-delay t)))))))))) | |||||
| (defun ccm-first-start (animate) | |||||
| "Called from centered-cursor-mode. Animate at first start, if | |||||
| centered-cursor-mode is called interactively." | |||||
| (let ((animate-first-start-p animate)) | |||||
| (ccm-vpos-recenter) | |||||
| (ccm-position-cursor))) | |||||
| ;;(defalias 'ccm 'centered-cursor-mode) | |||||
| ;;;###autoload | |||||
| (define-minor-mode centered-cursor-mode | |||||
| "Makes the cursor stay vertically in a defined | |||||
| position (usually centered)." | |||||
| :init-value nil | |||||
| ;; :lighter nil | |||||
| :lighter " ¢" | |||||
| :keymap ccm-map | |||||
| (cond | |||||
| (centered-cursor-mode | |||||
| (ccm-first-start (interactive-p)) | |||||
| (add-hook 'post-command-hook 'ccm-position-cursor t t) | |||||
| (add-hook 'window-configuration-change-hook 'ccm-vpos-recenter t t)) | |||||
| (t | |||||
| (remove-hook 'post-command-hook 'ccm-position-cursor t) | |||||
| (remove-hook 'window-configuration-change-hook 'ccm-vpos-recenter t)))) | |||||
| (define-global-minor-mode global-centered-cursor-mode centered-cursor-mode | |||||
| centered-cursor-mode) | |||||
| (provide 'centered-cursor-mode) | |||||
| ;;; Help: | |||||
| ;; (info "(elisp)Defining Minor Modes") | |||||
| ;; (info "(elisp)Screen Lines") | |||||
| ;; (info "(elisp)Hooks") | |||||
| ;; (info "(elisp)Customization") | |||||
| ;; (find-function 'mwheel-scroll) | |||||
| ;; Local Variables: | |||||
| ;; coding: utf-8 | |||||
| ;; End: | |||||
| ;;; centered-cursor-mode.el ends here | |||||
| @ -1,293 +0,0 @@ | |||||
| ;;; company-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil "company" "company.el" (21570 28046 0 0)) | |||||
| ;;; Generated autoloads from company.el | |||||
| (autoload 'company-mode "company" "\ | |||||
| \"complete anything\"; is an in-buffer completion framework. | |||||
| Completion starts automatically, depending on the values | |||||
| `company-idle-delay' and `company-minimum-prefix-length'. | |||||
| Completion can be controlled with the commands: | |||||
| `company-complete-common', `company-complete-selection', `company-complete', | |||||
| `company-select-next', `company-select-previous'. If these commands are | |||||
| called before `company-idle-delay', completion will also start. | |||||
| Completions can be searched with `company-search-candidates' or | |||||
| `company-filter-candidates'. These can be used while completion is | |||||
| inactive, as well. | |||||
| The completion data is retrieved using `company-backends' and displayed | |||||
| using `company-frontends'. If you want to start a specific back-end, call | |||||
| it interactively or use `company-begin-backend'. | |||||
| regular keymap (`company-mode-map'): | |||||
| \\{company-mode-map} | |||||
| keymap during active completions (`company-active-map'): | |||||
| \\{company-active-map} | |||||
| \(fn &optional ARG)" t nil) | |||||
| (defvar global-company-mode nil "\ | |||||
| Non-nil if Global-Company mode is enabled. | |||||
| See the command `global-company-mode' for a description of this minor mode. | |||||
| Setting this variable directly does not take effect; | |||||
| either customize it (see the info node `Easy Customization') | |||||
| or call the function `global-company-mode'.") | |||||
| (custom-autoload 'global-company-mode "company" nil) | |||||
| (autoload 'global-company-mode "company" "\ | |||||
| Toggle Company mode in all buffers. | |||||
| With prefix ARG, enable Global-Company mode if ARG is positive; | |||||
| otherwise, disable it. If called from Lisp, enable the mode if | |||||
| ARG is omitted or nil. | |||||
| Company mode is enabled in all buffers where | |||||
| `company-mode-on' would do it. | |||||
| See `company-mode' for more information on Company mode. | |||||
| \(fn &optional ARG)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-abbrev" "company-abbrev.el" (21570 | |||||
| ;;;;;; 28046 0 0)) | |||||
| ;;; Generated autoloads from company-abbrev.el | |||||
| (autoload 'company-abbrev "company-abbrev" "\ | |||||
| `company-mode' completion back-end for abbrev. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-bbdb" "company-bbdb.el" (21570 28046 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-bbdb.el | |||||
| (autoload 'company-bbdb "company-bbdb" "\ | |||||
| `company-mode' completion back-end for `bbdb'. | |||||
| \(fn COMMAND &optional ARG &rest IGNORE)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-css" "company-css.el" (21570 28046 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-css.el | |||||
| (autoload 'company-css "company-css" "\ | |||||
| `company-mode' completion back-end for `css-mode'. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-dabbrev" "company-dabbrev.el" (21570 | |||||
| ;;;;;; 28046 0 0)) | |||||
| ;;; Generated autoloads from company-dabbrev.el | |||||
| (autoload 'company-dabbrev "company-dabbrev" "\ | |||||
| dabbrev-like `company-mode' completion back-end. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-dabbrev-code" "company-dabbrev-code.el" | |||||
| ;;;;;; (21570 28046 0 0)) | |||||
| ;;; Generated autoloads from company-dabbrev-code.el | |||||
| (autoload 'company-dabbrev-code "company-dabbrev-code" "\ | |||||
| dabbrev-like `company-mode' back-end for code. | |||||
| The back-end looks for all symbols in the current buffer that aren't in | |||||
| comments or strings. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-elisp" "company-elisp.el" (21570 28046 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-elisp.el | |||||
| (autoload 'company-elisp "company-elisp" "\ | |||||
| `company-mode' completion back-end for Emacs Lisp. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-etags" "company-etags.el" (21570 28046 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-etags.el | |||||
| (autoload 'company-etags "company-etags" "\ | |||||
| `company-mode' completion back-end for etags. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-files" "company-files.el" (21570 28046 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-files.el | |||||
| (autoload 'company-files "company-files" "\ | |||||
| `company-mode' completion back-end existing file names. | |||||
| Completions works for proper absolute and relative files paths. | |||||
| File paths with spaces are only supported inside strings. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-gtags" "company-gtags.el" (21570 28046 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-gtags.el | |||||
| (autoload 'company-gtags "company-gtags" "\ | |||||
| `company-mode' completion back-end for GNU Global. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-ispell" "company-ispell.el" (21570 | |||||
| ;;;;;; 28046 0 0)) | |||||
| ;;; Generated autoloads from company-ispell.el | |||||
| (autoload 'company-ispell "company-ispell" "\ | |||||
| `company-mode' completion back-end using Ispell. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-keywords" "company-keywords.el" (21570 | |||||
| ;;;;;; 28046 0 0)) | |||||
| ;;; Generated autoloads from company-keywords.el | |||||
| (autoload 'company-keywords "company-keywords" "\ | |||||
| `company-mode' back-end for programming language keywords. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-nxml" "company-nxml.el" (21570 28046 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-nxml.el | |||||
| (autoload 'company-nxml "company-nxml" "\ | |||||
| `company-mode' completion back-end for `nxml-mode'. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-oddmuse" "company-oddmuse.el" (21570 | |||||
| ;;;;;; 28046 0 0)) | |||||
| ;;; Generated autoloads from company-oddmuse.el | |||||
| (autoload 'company-oddmuse "company-oddmuse" "\ | |||||
| `company-mode' completion back-end for `oddmuse-mode'. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-pysmell" "company-pysmell.el" (21570 | |||||
| ;;;;;; 28046 0 0)) | |||||
| ;;; Generated autoloads from company-pysmell.el | |||||
| (autoload 'company-pysmell "company-pysmell" "\ | |||||
| `company-mode' completion back-end for pysmell. | |||||
| This requires pysmell.el and pymacs.el. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-semantic" "company-semantic.el" (21570 | |||||
| ;;;;;; 28046 0 0)) | |||||
| ;;; Generated autoloads from company-semantic.el | |||||
| (autoload 'company-semantic "company-semantic" "\ | |||||
| `company-mode' completion back-end using CEDET Semantic. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-tempo" "company-tempo.el" (21570 28046 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-tempo.el | |||||
| (autoload 'company-tempo "company-tempo" "\ | |||||
| `company-mode' completion back-end for tempo. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-xcode" "company-xcode.el" (21570 28046 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-xcode.el | |||||
| (autoload 'company-xcode "company-xcode" "\ | |||||
| `company-mode' completion back-end for Xcode projects. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-yasnippet" "company-yasnippet.el" | |||||
| ;;;;;; (21570 28046 0 0)) | |||||
| ;;; Generated autoloads from company-yasnippet.el | |||||
| (autoload 'company-yasnippet "company-yasnippet" "\ | |||||
| `company-mode' back-end for `yasnippet'. | |||||
| This back-end should be used with care, because as long as there are | |||||
| snippets defined for the current major mode, this back-end will always | |||||
| shadow back-ends that come after it. Recommended usages: | |||||
| * In a buffer-local value of `company-backends', grouped with a back-end or | |||||
| several that provide actual text completions. | |||||
| (add-hook 'js-mode-hook | |||||
| (lambda () | |||||
| (set (make-local-variable 'company-backends) | |||||
| '((company-dabbrev-code company-yasnippet))))) | |||||
| * After keyword `:with', grouped with other back-ends. | |||||
| (push '(company-semantic :with company-yasnippet) company-backends) | |||||
| * Not in `company-backends', just bound to a key. | |||||
| (global-set-key (kbd \"C-c y\") 'company-yasnippet) | |||||
| \(fn COMMAND &optional ARG &rest IGNORE)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil nil ("company-capf.el" "company-clang.el" "company-cmake.el" | |||||
| ;;;;;; "company-eclim.el" "company-pkg.el" "company-ropemacs.el" | |||||
| ;;;;;; "company-template.el") (21570 28046 173750 0)) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; company-autoloads.el ends here | |||||
| @ -1,52 +0,0 @@ | |||||
| ;;; company-bbdb.el --- company-mode completion back-end for BBDB in message-mode | |||||
| ;; Copyright (C) 2013-2014 Free Software Foundation, Inc. | |||||
| ;; Author: Jan Tatarik <jan.tatarik@gmail.com> | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (declare-function bbdb-record-get-field "bbdb") | |||||
| (declare-function bbdb-records "bbdb") | |||||
| (declare-function bbdb-dwim-mail "bbdb-com") | |||||
| (declare-function bbdb-search "bbdb-com") | |||||
| (defun company-bbdb--candidates (arg) | |||||
| (cl-mapcan (lambda (record) | |||||
| (mapcar (lambda (mail) (bbdb-dwim-mail record mail)) | |||||
| (bbdb-record-get-field record 'mail))) | |||||
| (eval '(bbdb-search (bbdb-records) arg nil arg)))) | |||||
| ;;;###autoload | |||||
| (defun company-bbdb (command &optional arg &rest ignore) | |||||
| "`company-mode' completion back-end for `bbdb'." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-bbdb)) | |||||
| (prefix (and (eq major-mode 'message-mode) | |||||
| (featurep 'bbdb-com) | |||||
| (looking-back "^\\(To\\|Cc\\|Bcc\\):.*" | |||||
| (line-beginning-position)) | |||||
| (company-grab-symbol))) | |||||
| (candidates (company-bbdb--candidates arg)) | |||||
| (sorted t) | |||||
| (no-cache t))) | |||||
| (provide 'company-bbdb) | |||||
| ;;; company-bbdb.el ends here | |||||
| @ -1,148 +0,0 @@ | |||||
| ;;; company-capf.el --- company-mode completion-at-point-functions back-end -*- lexical-binding: t -*- | |||||
| ;; Copyright (C) 2013-2014 Free Software Foundation, Inc. | |||||
| ;; Author: Stefan Monnier <monnier@iro.umontreal.ca> | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defvar company--capf-cache nil) | |||||
| (defun company--capf-data () | |||||
| (let ((cache company--capf-cache)) | |||||
| (if (and (equal (current-buffer) (car cache)) | |||||
| (equal (point) (car (setq cache (cdr cache)))) | |||||
| (equal (buffer-chars-modified-tick) (car (setq cache (cdr cache))))) | |||||
| (cadr cache) | |||||
| (let ((data (company--capf-data-real))) | |||||
| (setq company--capf-cache | |||||
| (list (current-buffer) (point) (buffer-chars-modified-tick) data)) | |||||
| data)))) | |||||
| (defun company--capf-data-real () | |||||
| (cl-letf* (((default-value 'completion-at-point-functions) | |||||
| ;; Ignore tags-completion-at-point-function because it subverts | |||||
| ;; company-etags in the default value of company-backends, where | |||||
| ;; the latter comes later. | |||||
| (remove 'tags-completion-at-point-function | |||||
| (default-value 'completion-at-point-functions))) | |||||
| (data (run-hook-wrapped 'completion-at-point-functions | |||||
| ;; Ignore misbehaving functions. | |||||
| #'completion--capf-wrapper 'optimist))) | |||||
| (when (and (consp (cdr data)) (numberp (nth 1 data))) data))) | |||||
| (defun company-capf (command &optional arg &rest _args) | |||||
| "`company-mode' back-end using `completion-at-point-functions'." | |||||
| (interactive (list 'interactive)) | |||||
| (pcase command | |||||
| (`interactive (company-begin-backend 'company-capf)) | |||||
| (`prefix | |||||
| (let ((res (company--capf-data))) | |||||
| (when res | |||||
| (if (> (nth 2 res) (point)) | |||||
| 'stop | |||||
| (buffer-substring-no-properties (nth 1 res) (point)))))) | |||||
| (`candidates | |||||
| (let ((res (company--capf-data))) | |||||
| (when res | |||||
| (let* ((table (nth 3 res)) | |||||
| (pred (plist-get (nthcdr 4 res) :predicate)) | |||||
| (meta (completion-metadata | |||||
| (buffer-substring (nth 1 res) (nth 2 res)) | |||||
| table pred)) | |||||
| (sortfun (cdr (assq 'display-sort-function meta))) | |||||
| (candidates (completion-all-completions arg table pred (length arg))) | |||||
| (last (last candidates)) | |||||
| (base-size (and (numberp (cdr last)) (cdr last)))) | |||||
| (when base-size | |||||
| (setcdr last nil)) | |||||
| (when sortfun | |||||
| (setq candidates (funcall sortfun candidates))) | |||||
| (if (not (zerop (or base-size 0))) | |||||
| (let ((before (substring arg 0 base-size))) | |||||
| (mapcar (lambda (candidate) | |||||
| (concat before candidate)) | |||||
| candidates)) | |||||
| candidates))))) | |||||
| (`sorted | |||||
| (let ((res (company--capf-data))) | |||||
| (when res | |||||
| (let ((meta (completion-metadata | |||||
| (buffer-substring (nth 1 res) (nth 2 res)) | |||||
| (nth 3 res) (plist-get (nthcdr 4 res) :predicate)))) | |||||
| (cdr (assq 'display-sort-function meta)))))) | |||||
| (`match | |||||
| ;; Can't just use 0 when base-size (see above) is non-zero. | |||||
| (let ((start (if (get-text-property 0 'font-lock-face arg) | |||||
| 0 | |||||
| (next-single-property-change 0 'font-lock-face arg)))) | |||||
| (when start | |||||
| ;; completions-common-part comes first, but we can't just look for this | |||||
| ;; value because it can be in a list. | |||||
| (or | |||||
| (let ((value (get-text-property start 'font-lock-face arg))) | |||||
| (text-property-not-all start (length arg) | |||||
| 'font-lock-face value arg)) | |||||
| (length arg))))) | |||||
| (`duplicates t) | |||||
| (`no-cache t) ;Not much can be done here, as long as we handle | |||||
| ;non-prefix matches. | |||||
| (`meta | |||||
| (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-docsig))) | |||||
| (when f (funcall f arg)))) | |||||
| (`doc-buffer | |||||
| (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-doc-buffer))) | |||||
| (when f (funcall f arg)))) | |||||
| (`location | |||||
| (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-location))) | |||||
| (when f (funcall f arg)))) | |||||
| (`annotation | |||||
| (save-excursion | |||||
| ;; FIXME: `company-begin' sets `company-point' after calling | |||||
| ;; `company--begin-new'. We shouldn't rely on `company-point' here, | |||||
| ;; better to cache the capf-data value instead. However: we can't just | |||||
| ;; save the last capf-data value in `prefix', because that command can | |||||
| ;; get called more often than `candidates', and at any point in the | |||||
| ;; buffer (https://github.com/company-mode/company-mode/issues/153). | |||||
| ;; We could try propertizing the returned prefix string, but it's not | |||||
| ;; passed to `annotation', and `company-prefix' is set only after | |||||
| ;; `company--strip-duplicates' is called. | |||||
| (when company-point | |||||
| (goto-char company-point)) | |||||
| (let ((f (plist-get (nthcdr 4 (company--capf-data)) :annotation-function))) | |||||
| (when f (funcall f arg))))) | |||||
| (`require-match | |||||
| (plist-get (nthcdr 4 (company--capf-data)) :company-require-match)) | |||||
| (`init nil) ;Don't bother: plenty of other ways to initialize the code. | |||||
| (`post-completion | |||||
| (let* ((res (company--capf-data)) | |||||
| (exit-function (plist-get (nthcdr 4 res) :exit-function))) | |||||
| (if exit-function | |||||
| (funcall exit-function arg 'finished)))) | |||||
| )) | |||||
| (provide 'company-capf) | |||||
| ;;; company-capf.el ends here | |||||
| @ -1,327 +0,0 @@ | |||||
| ;;; company-clang.el --- company-mode completion back-end for Clang -*- lexical-binding: t -*- | |||||
| ;; Copyright (C) 2009, 2011, 2013-2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'company-template) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-clang nil | |||||
| "Completion back-end for Clang." | |||||
| :group 'company) | |||||
| (defcustom company-clang-executable | |||||
| (executable-find "clang") | |||||
| "Location of clang executable." | |||||
| :type 'file) | |||||
| (defcustom company-clang-begin-after-member-access t | |||||
| "When non-nil, automatic completion will start whenever the current | |||||
| symbol is preceded by \".\", \"->\" or \"::\", ignoring | |||||
| `company-minimum-prefix-length'. | |||||
| If `company-begin-commands' is a list, it should include `c-electric-lt-gt' | |||||
| and `c-electric-colon', for automatic completion right after \">\" and | |||||
| \":\".") | |||||
| (defcustom company-clang-arguments nil | |||||
| "Additional arguments to pass to clang when completing. | |||||
| Prefix files (-include ...) can be selected with `company-clang-set-prefix' | |||||
| or automatically through a custom `company-clang-prefix-guesser'." | |||||
| :type '(repeat (string :tag "Argument"))) | |||||
| (defcustom company-clang-prefix-guesser 'company-clang-guess-prefix | |||||
| "A function to determine the prefix file for the current buffer." | |||||
| :type '(function :tag "Guesser function" nil)) | |||||
| (defvar company-clang-modes '(c-mode c++-mode objc-mode) | |||||
| "Major modes which clang may complete.") | |||||
| (defcustom company-clang-insert-arguments t | |||||
| "When non-nil, insert function arguments as a template after completion." | |||||
| :type 'boolean | |||||
| :package-version '(company . "0.8.0")) | |||||
| ;; prefix ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defvar company-clang--prefix nil) | |||||
| (defsubst company-clang--guess-pch-file (file) | |||||
| (let ((dir (directory-file-name (file-name-directory file)))) | |||||
| (when (equal (file-name-nondirectory dir) "Classes") | |||||
| (setq dir (file-name-directory dir))) | |||||
| (car (directory-files dir t "\\([^.]h\\|[^h]\\).pch\\'" t)))) | |||||
| (defsubst company-clang--file-substring (file beg end) | |||||
| (with-temp-buffer | |||||
| (insert-file-contents-literally file nil beg end) | |||||
| (buffer-string))) | |||||
| (defun company-clang-guess-prefix () | |||||
| "Try to guess the prefix file for the current buffer." | |||||
| ;; Prefixes seem to be called .pch. Pre-compiled headers do, too. | |||||
| ;; So we look at the magic number to rule them out. | |||||
| (let* ((file (company-clang--guess-pch-file buffer-file-name)) | |||||
| (magic-number (and file (company-clang--file-substring file 0 4)))) | |||||
| (unless (member magic-number '("CPCH" "gpch")) | |||||
| file))) | |||||
| (defun company-clang-set-prefix (&optional prefix) | |||||
| "Use PREFIX as a prefix (-include ...) file for clang completion." | |||||
| (interactive (let ((def (funcall company-clang-prefix-guesser))) | |||||
| (unless (stringp def) | |||||
| (setq def default-directory)) | |||||
| (list (read-file-name "Prefix file: " | |||||
| (when def (file-name-directory def)) | |||||
| def t (when def (file-name-nondirectory def)))))) | |||||
| ;; TODO: pre-compile? | |||||
| (setq company-clang--prefix (and (stringp prefix) | |||||
| (file-regular-p prefix) | |||||
| prefix))) | |||||
| ;; Clean-up on exit. | |||||
| (add-hook 'kill-emacs-hook 'company-clang-set-prefix) | |||||
| ;; parsing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| ;; TODO: Handle Pattern (syntactic hints would be neat). | |||||
| ;; Do we ever see OVERLOAD (or OVERRIDE)? | |||||
| (defconst company-clang--completion-pattern | |||||
| "^COMPLETION: \\_<\\(%s[a-zA-Z0-9_:<>]*\\)\\(?: : \\(.*\\)$\\)?$") | |||||
| (defconst company-clang--error-buffer-name "*clang-error*") | |||||
| (defun company-clang--lang-option () | |||||
| (if (eq major-mode 'objc-mode) | |||||
| (if (string= "m" (file-name-extension buffer-file-name)) | |||||
| "objective-c" "objective-c++") | |||||
| (substring (symbol-name major-mode) 0 -5))) | |||||
| (defun company-clang--parse-output (prefix _objc) | |||||
| (goto-char (point-min)) | |||||
| (let ((pattern (format company-clang--completion-pattern | |||||
| (regexp-quote prefix))) | |||||
| (case-fold-search nil) | |||||
| lines match) | |||||
| (while (re-search-forward pattern nil t) | |||||
| (setq match (match-string-no-properties 1)) | |||||
| (unless (equal match "Pattern") | |||||
| (save-match-data | |||||
| (when (string-match ":" match) | |||||
| (setq match (substring match 0 (match-beginning 0))))) | |||||
| (let ((meta (match-string-no-properties 2))) | |||||
| (when (and meta (not (string= match meta))) | |||||
| (put-text-property 0 1 'meta | |||||
| (company-clang--strip-formatting meta) | |||||
| match))) | |||||
| (push match lines))) | |||||
| lines)) | |||||
| (defun company-clang--meta (candidate) | |||||
| (get-text-property 0 'meta candidate)) | |||||
| (defun company-clang--annotation (candidate) | |||||
| (let ((meta (company-clang--meta candidate))) | |||||
| (cond | |||||
| ((null meta) nil) | |||||
| ((string-match "[^:]:[^:]" meta) | |||||
| (substring meta (1+ (match-beginning 0)))) | |||||
| ((string-match "\\((.*)[ a-z]*\\'\\)" meta) | |||||
| (match-string 1 meta))))) | |||||
| (defun company-clang--strip-formatting (text) | |||||
| (replace-regexp-in-string | |||||
| "#]" " " | |||||
| (replace-regexp-in-string "[<{[]#\\|#[>}]" "" text t) | |||||
| t)) | |||||
| (defun company-clang--handle-error (res args) | |||||
| (goto-char (point-min)) | |||||
| (let* ((buf (get-buffer-create company-clang--error-buffer-name)) | |||||
| (cmd (concat company-clang-executable " " (mapconcat 'identity args " "))) | |||||
| (pattern (format company-clang--completion-pattern "")) | |||||
| (err (if (re-search-forward pattern nil t) | |||||
| (buffer-substring-no-properties (point-min) | |||||
| (1- (match-beginning 0))) | |||||
| ;; Warn the user more aggressively if no match was found. | |||||
| (message "clang failed with error %d:\n%s" res cmd) | |||||
| (buffer-string)))) | |||||
| (with-current-buffer buf | |||||
| (let ((inhibit-read-only t)) | |||||
| (erase-buffer) | |||||
| (insert (current-time-string) | |||||
| (format "\nclang failed with error %d:\n" res) | |||||
| cmd "\n\n") | |||||
| (insert err) | |||||
| (setq buffer-read-only t) | |||||
| (goto-char (point-min)))))) | |||||
| (defun company-clang--start-process (prefix callback &rest args) | |||||
| (let ((objc (derived-mode-p 'objc-mode)) | |||||
| (buf (get-buffer-create "*clang-output*"))) | |||||
| (with-current-buffer buf (erase-buffer)) | |||||
| (if (get-buffer-process buf) | |||||
| (funcall callback nil) | |||||
| (let ((process (apply #'start-process "company-clang" buf | |||||
| company-clang-executable args))) | |||||
| (set-process-sentinel | |||||
| process | |||||
| (lambda (proc status) | |||||
| (unless (string-match-p "hangup" status) | |||||
| (funcall | |||||
| callback | |||||
| (let ((res (process-exit-status proc))) | |||||
| (with-current-buffer buf | |||||
| (unless (eq 0 res) | |||||
| (company-clang--handle-error res args)) | |||||
| ;; Still try to get any useful input. | |||||
| (company-clang--parse-output prefix objc))))))) | |||||
| (unless (company-clang--auto-save-p) | |||||
| (send-region process (point-min) (point-max)) | |||||
| (send-string process "\n") | |||||
| (process-send-eof process)))))) | |||||
| (defsubst company-clang--build-location (pos) | |||||
| (save-excursion | |||||
| (goto-char pos) | |||||
| (format "%s:%d:%d" | |||||
| (if (company-clang--auto-save-p) buffer-file-name "-") | |||||
| (line-number-at-pos) | |||||
| (1+ (length | |||||
| (encode-coding-region | |||||
| (line-beginning-position) | |||||
| (point) | |||||
| 'utf-8 | |||||
| t)))))) | |||||
| (defsubst company-clang--build-complete-args (pos) | |||||
| (append '("-fsyntax-only" "-Xclang" "-code-completion-macros") | |||||
| (unless (company-clang--auto-save-p) | |||||
| (list "-x" (company-clang--lang-option))) | |||||
| company-clang-arguments | |||||
| (when (stringp company-clang--prefix) | |||||
| (list "-include" (expand-file-name company-clang--prefix))) | |||||
| (list "-Xclang" (format "-code-completion-at=%s" | |||||
| (company-clang--build-location pos))) | |||||
| (list (if (company-clang--auto-save-p) buffer-file-name "-")))) | |||||
| (defun company-clang--candidates (prefix callback) | |||||
| (and (company-clang--auto-save-p) | |||||
| (buffer-modified-p) | |||||
| (basic-save-buffer)) | |||||
| (when (null company-clang--prefix) | |||||
| (company-clang-set-prefix (or (funcall company-clang-prefix-guesser) | |||||
| 'none))) | |||||
| (apply 'company-clang--start-process | |||||
| prefix | |||||
| callback | |||||
| (company-clang--build-complete-args (- (point) (length prefix))))) | |||||
| (defun company-clang--prefix () | |||||
| (if company-clang-begin-after-member-access | |||||
| (company-grab-symbol-cons "\\.\\|->\\|::" 2) | |||||
| (company-grab-symbol))) | |||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defconst company-clang-required-version 1.1) | |||||
| (defvar company-clang--version nil) | |||||
| (defun company-clang--auto-save-p () | |||||
| (< company-clang--version 2.9)) | |||||
| (defsubst company-clang-version () | |||||
| "Return the version of `company-clang-executable'." | |||||
| (with-temp-buffer | |||||
| (call-process company-clang-executable nil t nil "--version") | |||||
| (goto-char (point-min)) | |||||
| (if (re-search-forward "clang\\(?: version \\|-\\)\\([0-9.]+\\)" nil t) | |||||
| (let ((ver (string-to-number (match-string-no-properties 1)))) | |||||
| (if (> ver 100) | |||||
| (/ ver 100) | |||||
| ver)) | |||||
| 0))) | |||||
| (defun company-clang-objc-templatify (selector) | |||||
| (let* ((end (point-marker)) | |||||
| (beg (- (point) (length selector) 1)) | |||||
| (templ (company-template-declare-template beg end)) | |||||
| (cnt 0)) | |||||
| (save-excursion | |||||
| (goto-char beg) | |||||
| (catch 'stop | |||||
| (while (search-forward ":" end t) | |||||
| (when (looking-at "([^)]*) ?") | |||||
| (delete-region (match-beginning 0) (match-end 0))) | |||||
| (company-template-add-field templ (point) (format "arg%d" cnt)) | |||||
| (if (< (point) end) | |||||
| (insert " ") | |||||
| (throw 'stop t)) | |||||
| (cl-incf cnt)))) | |||||
| (company-template-move-to-first templ))) | |||||
| (defun company-clang (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for Clang. | |||||
| Clang is a parser for C and ObjC. Clang version 1.1 or newer is required. | |||||
| Additional command line arguments can be specified in | |||||
| `company-clang-arguments'. Prefix files (-include ...) can be selected | |||||
| with `company-clang-set-prefix' or automatically through a custom | |||||
| `company-clang-prefix-guesser'. | |||||
| With Clang versions before 2.9, we have to save the buffer before | |||||
| performing completion. With Clang 2.9 and later, buffer contents are | |||||
| passed via standard input." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-clang)) | |||||
| (init (when (memq major-mode company-clang-modes) | |||||
| (unless company-clang-executable | |||||
| (error "Company found no clang executable")) | |||||
| (setq company-clang--version (company-clang-version)) | |||||
| (when (< company-clang--version company-clang-required-version) | |||||
| (error "Company requires clang version 1.1")))) | |||||
| (prefix (and (memq major-mode company-clang-modes) | |||||
| buffer-file-name | |||||
| company-clang-executable | |||||
| (not (company-in-string-or-comment)) | |||||
| (or (company-clang--prefix) 'stop))) | |||||
| (candidates (cons :async | |||||
| (lambda (cb) (company-clang--candidates arg cb)))) | |||||
| (meta (company-clang--meta arg)) | |||||
| (annotation (company-clang--annotation arg)) | |||||
| (post-completion (let ((anno (company-clang--annotation arg))) | |||||
| (when (and company-clang-insert-arguments anno) | |||||
| (insert anno) | |||||
| (if (string-match "\\`:[^:]" anno) | |||||
| (company-clang-objc-templatify anno) | |||||
| (company-template-c-like-templatify | |||||
| (concat arg anno)))))))) | |||||
| (provide 'company-clang) | |||||
| ;;; company-clang.el ends here | |||||
| @ -1,129 +0,0 @@ | |||||
| ;;; company-cmake.el --- company-mode completion back-end for CMake | |||||
| ;; Copyright (C) 2013 Free Software Foundation, Inc. | |||||
| ;; Author: Chen Bin <chenbin DOT sh AT gmail> | |||||
| ;; Version: 0.1 | |||||
| ;; This program is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; This program is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;; company-cmake offers completions for module names, variable names and | |||||
| ;; commands used by CMake. And their descriptions. | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-cmake nil | |||||
| "Completion back-end for CMake." | |||||
| :group 'company) | |||||
| (defcustom company-cmake-executable | |||||
| (executable-find "cmake") | |||||
| "Location of cmake executable." | |||||
| :type 'file) | |||||
| (defvar company-cmake-executable-arguments | |||||
| '("--help-command-list" | |||||
| "--help-module-list" | |||||
| "--help-variable-list") | |||||
| "The arguments we pass to cmake, separately. | |||||
| They affect which types of symbols we get completion candidates for.") | |||||
| (defvar company-cmake--completion-pattern | |||||
| "^\\(%s[a-zA-Z0-9_]%s\\)$" | |||||
| "Regexp to match the candidates.") | |||||
| (defvar company-cmake-modes '(cmake-mode) | |||||
| "Major modes in which cmake may complete.") | |||||
| (defvar company-cmake--meta-command-cache nil | |||||
| "Cache for command arguments to retrieve descriptions for the candidates.") | |||||
| (defun company-cmake--parse-output (prefix cmd) | |||||
| "Analyze the temp buffer and collect lines." | |||||
| (goto-char (point-min)) | |||||
| (let ((pattern (format company-cmake--completion-pattern | |||||
| (regexp-quote prefix) | |||||
| (if (zerop (length prefix)) "+" "*"))) | |||||
| (case-fold-search nil) | |||||
| lines match) | |||||
| (while (re-search-forward pattern nil t) | |||||
| (setq match (match-string-no-properties 1)) | |||||
| (puthash match cmd company-cmake--meta-command-cache) | |||||
| (push match lines)) | |||||
| lines)) | |||||
| (defun company-cmake--candidates (prefix) | |||||
| (let ((res 0) | |||||
| results | |||||
| cmd) | |||||
| (setq company-cmake--meta-command-cache (make-hash-table :test 'equal)) | |||||
| (dolist (arg company-cmake-executable-arguments) | |||||
| (with-temp-buffer | |||||
| (setq res (call-process company-cmake-executable nil t nil arg)) | |||||
| (unless (eq 0 res) | |||||
| (message "cmake executable exited with error=%d" res)) | |||||
| (setq cmd (replace-regexp-in-string "-list$" "" arg) ) | |||||
| (setq results (nconc results (company-cmake--parse-output prefix cmd))))) | |||||
| results)) | |||||
| (defun company-cmake--meta (prefix) | |||||
| (let ((cmd-opts (gethash prefix company-cmake--meta-command-cache)) | |||||
| result) | |||||
| (with-temp-buffer | |||||
| (call-process company-cmake-executable nil t nil cmd-opts prefix) | |||||
| ;; Go to the third line, trim it and return the result. | |||||
| ;; Tested with cmake 2.8.9. | |||||
| (goto-char (point-min)) | |||||
| (forward-line 2) | |||||
| (setq result (buffer-substring-no-properties (line-beginning-position) | |||||
| (line-end-position))) | |||||
| (setq result (replace-regexp-in-string "^[ \t\n\r]+" "" result)) | |||||
| result))) | |||||
| (defun company-cmake--doc-buffer (prefix) | |||||
| (let ((cmd-opts (gethash prefix company-cmake--meta-command-cache))) | |||||
| (with-temp-buffer | |||||
| (call-process company-cmake-executable nil t nil cmd-opts prefix) | |||||
| ;; Go to the third line, trim it and return the doc buffer. | |||||
| ;; Tested with cmake 2.8.9. | |||||
| (goto-char (point-min)) | |||||
| (forward-line 2) | |||||
| (company-doc-buffer | |||||
| (buffer-substring-no-properties (line-beginning-position) | |||||
| (point-max)))))) | |||||
| (defun company-cmake (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for CMake. | |||||
| CMake is a cross-platform, open-source make system." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-cmake)) | |||||
| (init (when (memq major-mode company-cmake-modes) | |||||
| (unless company-cmake-executable | |||||
| (error "Company found no cmake executable")))) | |||||
| (prefix (and (memq major-mode company-cmake-modes) | |||||
| (not (company-in-string-or-comment)) | |||||
| (company-grab-symbol))) | |||||
| (candidates (company-cmake--candidates arg)) | |||||
| (meta (company-cmake--meta arg)) | |||||
| (doc-buffer (company-cmake--doc-buffer arg)) | |||||
| )) | |||||
| (provide 'company-cmake) | |||||
| ;;; company-cmake.el ends here | |||||
| @ -1,163 +0,0 @@ | |||||
| ;;; company-dabbrev.el --- dabbrev-like company-mode completion back-end -*- lexical-binding: t -*- | |||||
| ;; Copyright (C) 2009, 2011, 2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-dabbrev nil | |||||
| "dabbrev-like completion back-end." | |||||
| :group 'company) | |||||
| (defcustom company-dabbrev-other-buffers 'all | |||||
| "Determines whether `company-dabbrev' should search other buffers. | |||||
| If `all', search all other buffers, except the ignored ones. If t, search | |||||
| buffers with the same major mode. See also `company-dabbrev-time-limit'." | |||||
| :type '(choice (const :tag "Off" nil) | |||||
| (const :tag "Same major mode" t) | |||||
| (const :tag "All" all))) | |||||
| (defcustom company-dabbrev-ignore-buffers "\\`[ *]" | |||||
| "Regexp matching the names of buffers to ignore." | |||||
| :type 'regexp) | |||||
| (defcustom company-dabbrev-time-limit .1 | |||||
| "Determines how many seconds `company-dabbrev' should look for matches." | |||||
| :type '(choice (const :tag "Off" nil) | |||||
| (number :tag "Seconds"))) | |||||
| (defcustom company-dabbrev-char-regexp "\\sw" | |||||
| "A regular expression matching the characters `company-dabbrev' looks for." | |||||
| :type 'regexp) | |||||
| (defcustom company-dabbrev-ignore-case 'keep-prefix | |||||
| "Non-nil to ignore case when collecting completion candidates. | |||||
| When it's `keep-prefix', the text before point will remain unchanged after | |||||
| candidate is inserted, even some of its characters have different case.") | |||||
| (defcustom company-dabbrev-downcase 'case-replace | |||||
| "Whether to downcase the returned candidates. | |||||
| The value of nil means keep them as-is. | |||||
| `case-replace' means use the value of `case-replace'. | |||||
| Any other value means downcase. | |||||
| If you set this value to nil, you may also want to set | |||||
| `company-dabbrev-ignore-case' to any value other than `keep-prefix'.") | |||||
| (defcustom company-dabbrev-minimum-length 4 | |||||
| "The minimum length for the completion candidate to be included. | |||||
| This variable affects both `company-dabbrev' and `company-dabbrev-code'." | |||||
| :type 'integer | |||||
| :package-version '(company . "0.8.3")) | |||||
| (defmacro company-dabrev--time-limit-while (test start limit &rest body) | |||||
| (declare (indent 3) (debug t)) | |||||
| `(let ((company-time-limit-while-counter 0)) | |||||
| (catch 'done | |||||
| (while ,test | |||||
| ,@body | |||||
| (and ,limit | |||||
| (eq (cl-incf company-time-limit-while-counter) 25) | |||||
| (setq company-time-limit-while-counter 0) | |||||
| (> (float-time (time-since ,start)) ,limit) | |||||
| (throw 'done 'company-time-out)))))) | |||||
| (defsubst company-dabbrev--make-regexp (prefix) | |||||
| (concat "\\<" (if (equal prefix "") | |||||
| company-dabbrev-char-regexp | |||||
| (regexp-quote prefix)) | |||||
| "\\(" company-dabbrev-char-regexp "\\)*\\>")) | |||||
| (defun company-dabbrev--search-buffer (regexp pos symbols start limit | |||||
| ignore-comments) | |||||
| (save-excursion | |||||
| (let (match) | |||||
| (goto-char (if pos (1- pos) (point-min))) | |||||
| ;; search before pos | |||||
| (company-dabrev--time-limit-while (re-search-backward regexp nil t) | |||||
| start limit | |||||
| (setq match (match-string-no-properties 0)) | |||||
| (if (and ignore-comments (company-in-string-or-comment)) | |||||
| (goto-char (nth 8 (syntax-ppss))) | |||||
| (when (>= (length match) company-dabbrev-minimum-length) | |||||
| (push match symbols)))) | |||||
| (goto-char (or pos (point-min))) | |||||
| ;; search after pos | |||||
| (company-dabrev--time-limit-while (re-search-forward regexp nil t) | |||||
| start limit | |||||
| (setq match (match-string-no-properties 0)) | |||||
| (if (and ignore-comments (company-in-string-or-comment)) | |||||
| (re-search-forward "\\s>\\|\\s!\\|\\s\"" nil t) | |||||
| (when (>= (length match) company-dabbrev-minimum-length) | |||||
| (push match symbols)))) | |||||
| symbols))) | |||||
| (defun company-dabbrev--search (regexp &optional limit other-buffer-modes | |||||
| ignore-comments) | |||||
| (let* ((start (current-time)) | |||||
| (symbols (company-dabbrev--search-buffer regexp (point) nil start limit | |||||
| ignore-comments))) | |||||
| (when other-buffer-modes | |||||
| (cl-dolist (buffer (delq (current-buffer) (buffer-list))) | |||||
| (with-current-buffer buffer | |||||
| (when (if (eq other-buffer-modes 'all) | |||||
| (not (string-match-p company-dabbrev-ignore-buffers | |||||
| (buffer-name))) | |||||
| (apply #'derived-mode-p other-buffer-modes)) | |||||
| (setq symbols | |||||
| (company-dabbrev--search-buffer regexp nil symbols start | |||||
| limit ignore-comments)))) | |||||
| (and limit | |||||
| (> (float-time (time-since start)) limit) | |||||
| (cl-return)))) | |||||
| symbols)) | |||||
| ;;;###autoload | |||||
| (defun company-dabbrev (command &optional arg &rest ignored) | |||||
| "dabbrev-like `company-mode' completion back-end." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-dabbrev)) | |||||
| (prefix (company-grab-word)) | |||||
| (candidates | |||||
| (let* ((case-fold-search company-dabbrev-ignore-case) | |||||
| (words (company-dabbrev--search (company-dabbrev--make-regexp arg) | |||||
| company-dabbrev-time-limit | |||||
| (pcase company-dabbrev-other-buffers | |||||
| (`t (list major-mode)) | |||||
| (`all `all)))) | |||||
| (downcase-p (if (eq company-dabbrev-downcase 'case-replace) | |||||
| case-replace | |||||
| company-dabbrev-downcase))) | |||||
| (if downcase-p | |||||
| (mapcar 'downcase words) | |||||
| words))) | |||||
| (ignore-case company-dabbrev-ignore-case) | |||||
| (duplicates t))) | |||||
| (provide 'company-dabbrev) | |||||
| ;;; company-dabbrev.el ends here | |||||
| @ -1,94 +0,0 @@ | |||||
| ;;; company-etags.el --- company-mode completion back-end for etags | |||||
| ;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (require 'etags) | |||||
| (defgroup company-etags nil | |||||
| "Completion back-end for etags." | |||||
| :group 'company) | |||||
| (defcustom company-etags-use-main-table-list t | |||||
| "Always search `tags-table-list' if set. | |||||
| If this is disabled, `company-etags' will try to find the one table for each | |||||
| buffer automatically." | |||||
| :type '(choice (const :tag "off" nil) | |||||
| (const :tag "on" t))) | |||||
| (defcustom company-etags-ignore-case nil | |||||
| "Non-nil to ignore case in completion candidates." | |||||
| :type 'boolean | |||||
| :package-version '(company . "0.7.3")) | |||||
| (defvar company-etags-modes '(prog-mode c-mode objc-mode c++-mode java-mode | |||||
| jde-mode pascal-mode perl-mode python-mode)) | |||||
| (defvar-local company-etags-buffer-table 'unknown) | |||||
| (defun company-etags-find-table () | |||||
| (let ((file (locate-dominating-file (or buffer-file-name | |||||
| default-directory) | |||||
| "TAGS"))) | |||||
| (when file | |||||
| (list (expand-file-name file))))) | |||||
| (defun company-etags-buffer-table () | |||||
| (or (and company-etags-use-main-table-list tags-table-list) | |||||
| (if (eq company-etags-buffer-table 'unknown) | |||||
| (setq company-etags-buffer-table (company-etags-find-table)) | |||||
| company-etags-buffer-table))) | |||||
| (defun company-etags--candidates (prefix) | |||||
| (let ((tags-table-list (company-etags-buffer-table)) | |||||
| (completion-ignore-case company-etags-ignore-case)) | |||||
| (and (or tags-file-name tags-table-list) | |||||
| (fboundp 'tags-completion-table) | |||||
| (save-excursion | |||||
| (visit-tags-table-buffer) | |||||
| (all-completions prefix (tags-completion-table)))))) | |||||
| ;;;###autoload | |||||
| (defun company-etags (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for etags." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-etags)) | |||||
| (prefix (and (apply 'derived-mode-p company-etags-modes) | |||||
| (not (company-in-string-or-comment)) | |||||
| (company-etags-buffer-table) | |||||
| (or (company-grab-symbol) 'stop))) | |||||
| (candidates (company-etags--candidates arg)) | |||||
| (location (let ((tags-table-list (company-etags-buffer-table))) | |||||
| (when (fboundp 'find-tag-noselect) | |||||
| (save-excursion | |||||
| (let ((buffer (find-tag-noselect arg))) | |||||
| (cons buffer (with-current-buffer buffer (point)))))))) | |||||
| (ignore-case company-etags-ignore-case))) | |||||
| (provide 'company-etags) | |||||
| ;;; company-etags.el ends here | |||||
| @ -1,104 +0,0 @@ | |||||
| ;;; company-files.el --- company-mode completion back-end for file paths | |||||
| ;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defun company-files--directory-files (dir prefix) | |||||
| (ignore-errors | |||||
| (if (equal prefix "") | |||||
| (directory-files dir nil "\\`[^.]\\|\\`.[^.]") | |||||
| (file-name-all-completions prefix dir)))) | |||||
| (defvar company-files--regexps | |||||
| (let* ((root (if (eq system-type 'windows-nt) | |||||
| "[a-zA-Z]:/" | |||||
| "/")) | |||||
| (begin (concat "\\(?:\\.\\{1,2\\}/\\|~/\\|" root "\\)"))) | |||||
| (list (concat "\"\\(" begin "[^\"\n]*\\)") | |||||
| (concat "\'\\(" begin "[^\'\n]*\\)") | |||||
| (concat "\\(?:[ \t]\\|^\\)\\(" begin "[^ \t\n]*\\)")))) | |||||
| (defun company-files--grab-existing-name () | |||||
| ;; Grab the file name. | |||||
| ;; When surrounded with quotes, it can include spaces. | |||||
| (let (file dir) | |||||
| (and (cl-dolist (regexp company-files--regexps) | |||||
| (when (setq file (company-grab-line regexp 1)) | |||||
| (cl-return file))) | |||||
| (setq dir (file-name-directory file)) | |||||
| (not (string-match "//" dir)) | |||||
| (file-exists-p dir) | |||||
| (file-name-all-completions (file-name-nondirectory file) dir) | |||||
| file))) | |||||
| (defvar company-files--completion-cache nil) | |||||
| (defun company-files--complete (prefix) | |||||
| (let* ((dir (file-name-directory prefix)) | |||||
| (key (list (file-name-nondirectory prefix) | |||||
| (expand-file-name dir) | |||||
| (nth 5 (file-attributes dir)))) | |||||
| (file (file-name-nondirectory prefix)) | |||||
| candidates directories) | |||||
| (unless (company-file--keys-match-p key (car company-files--completion-cache)) | |||||
| (dolist (file (company-files--directory-files dir file)) | |||||
| (setq file (concat dir file)) | |||||
| (push file candidates) | |||||
| (when (file-directory-p file) | |||||
| (push file directories))) | |||||
| (dolist (directory (reverse directories)) | |||||
| ;; Add one level of children. | |||||
| (dolist (child (company-files--directory-files directory "")) | |||||
| (push (concat directory | |||||
| (unless (eq (aref directory (1- (length directory))) ?/) "/") | |||||
| child) candidates))) | |||||
| (setq company-files--completion-cache (cons key (nreverse candidates)))) | |||||
| (all-completions prefix | |||||
| (cdr company-files--completion-cache)))) | |||||
| (defun company-file--keys-match-p (new old) | |||||
| (and (equal (cdr old) (cdr new)) | |||||
| (string-prefix-p (car old) (car new)))) | |||||
| ;;;###autoload | |||||
| (defun company-files (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end existing file names. | |||||
| Completions works for proper absolute and relative files paths. | |||||
| File paths with spaces are only supported inside strings." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-files)) | |||||
| (prefix (company-files--grab-existing-name)) | |||||
| (candidates (company-files--complete arg)) | |||||
| (location (cons (dired-noselect | |||||
| (file-name-directory (directory-file-name arg))) 1)) | |||||
| (sorted t) | |||||
| (no-cache t))) | |||||
| (provide 'company-files) | |||||
| ;;; company-files.el ends here | |||||
| @ -1,115 +0,0 @@ | |||||
| ;;; company-gtags.el --- company-mode completion back-end for GNU Global | |||||
| ;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-gtags nil | |||||
| "Completion back-end for GNU Global." | |||||
| :group 'company) | |||||
| (defcustom company-gtags-executable | |||||
| (executable-find "global") | |||||
| "Location of GNU global executable." | |||||
| :type 'string) | |||||
| (define-obsolete-variable-alias | |||||
| 'company-gtags-gnu-global-program-name | |||||
| 'company-gtags-executable "earlier") | |||||
| (defcustom company-gtags-insert-arguments t | |||||
| "When non-nil, insert function arguments as a template after completion." | |||||
| :type 'boolean | |||||
| :package-version '(company . "0.8.1")) | |||||
| (defvar-local company-gtags--tags-available-p 'unknown) | |||||
| (defcustom company-gtags-modes '(prog-mode jde-mode) | |||||
| "Modes that use `company-gtags'. | |||||
| In all these modes (and their derivatives) `company-gtags' will perform | |||||
| completion." | |||||
| :type '(repeat (symbol :tag "Major mode")) | |||||
| :package-version '(company . "0.8.4")) | |||||
| (defun company-gtags--tags-available-p () | |||||
| (if (eq company-gtags--tags-available-p 'unknown) | |||||
| (setq company-gtags--tags-available-p | |||||
| (locate-dominating-file buffer-file-name "GTAGS")) | |||||
| company-gtags--tags-available-p)) | |||||
| (defun company-gtags--fetch-tags (prefix) | |||||
| (with-temp-buffer | |||||
| (let (tags) | |||||
| (when (= 0 (call-process company-gtags-executable nil | |||||
| (list (current-buffer) nil) nil "-xGq" (concat "^" prefix))) | |||||
| (goto-char (point-min)) | |||||
| (cl-loop while | |||||
| (re-search-forward (concat | |||||
| "^" | |||||
| "\\([^ ]*\\)" ;; completion | |||||
| "[ \t]+\\([[:digit:]]+\\)" ;; linum | |||||
| "[ \t]+\\([^ \t]+\\)" ;; file | |||||
| "[ \t]+\\(.*\\)" ;; definition | |||||
| "$" | |||||
| ) nil t) | |||||
| collect | |||||
| (propertize (match-string 1) | |||||
| 'meta (match-string 4) | |||||
| 'location (cons (expand-file-name (match-string 3)) | |||||
| (string-to-number (match-string 2))) | |||||
| )))))) | |||||
| (defun company-gtags--annotation (arg) | |||||
| (let ((meta (get-text-property 0 'meta arg))) | |||||
| (when (string-match (concat arg "\\((.*)\\).*") meta) | |||||
| (match-string 1 meta)))) | |||||
| ;;;###autoload | |||||
| (defun company-gtags (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for GNU Global." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-gtags)) | |||||
| (prefix (and company-gtags-executable | |||||
| buffer-file-name | |||||
| (apply #'derived-mode-p company-gtags-modes) | |||||
| (not (company-in-string-or-comment)) | |||||
| (company-gtags--tags-available-p) | |||||
| (or (company-grab-symbol) 'stop))) | |||||
| (candidates (company-gtags--fetch-tags arg)) | |||||
| (sorted t) | |||||
| (duplicates t) | |||||
| (annotation (company-gtags--annotation arg)) | |||||
| (meta (get-text-property 0 'meta arg)) | |||||
| (location (get-text-property 0 'location arg)) | |||||
| (post-completion (let ((anno (company-gtags--annotation arg))) | |||||
| (when (and company-gtags-insert-arguments anno) | |||||
| (insert anno) | |||||
| (company-template-c-like-templatify anno)))))) | |||||
| (provide 'company-gtags) | |||||
| ;;; company-gtags.el ends here | |||||
| @ -1,69 +0,0 @@ | |||||
| ;;; company-ispell.el --- company-mode completion back-end using Ispell | |||||
| ;; Copyright (C) 2009-2011 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (require 'ispell) | |||||
| (defgroup company-ispell nil | |||||
| "Completion back-end using Ispell." | |||||
| :group 'company) | |||||
| (defcustom company-ispell-dictionary nil | |||||
| "Dictionary to use for `company-ispell'. | |||||
| If nil, use `ispell-complete-word-dict'." | |||||
| :type '(choice (const :tag "default (nil)" nil) | |||||
| (file :tag "dictionary" t))) | |||||
| (defvar company-ispell-available 'unknown) | |||||
| (defun company-ispell-available () | |||||
| (when (eq company-ispell-available 'unknown) | |||||
| (condition-case err | |||||
| (progn | |||||
| (lookup-words "WHATEVER") | |||||
| (setq company-ispell-available t)) | |||||
| (error | |||||
| (message "Company: ispell-look-command not found") | |||||
| (setq company-ispell-available nil)))) | |||||
| company-ispell-available) | |||||
| ;;;###autoload | |||||
| (defun company-ispell (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end using Ispell." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-ispell)) | |||||
| (prefix (when (company-ispell-available) | |||||
| (company-grab-word))) | |||||
| (candidates (lookup-words arg (or company-ispell-dictionary | |||||
| ispell-complete-word-dict))) | |||||
| (sorted t) | |||||
| (ignore-case 'keep-prefix))) | |||||
| (provide 'company-ispell) | |||||
| ;;; company-ispell.el ends here | |||||
| @ -1,8 +0,0 @@ | |||||
| (define-package "company" "20141014.1517" "Modular text completion framework" | |||||
| '((emacs "24.1") | |||||
| (cl-lib "0.5")) | |||||
| :url "http://company-mode.github.io/" :keywords | |||||
| '("abbrev" "convenience" "matching")) | |||||
| ;; Local Variables: | |||||
| ;; no-byte-compile: t | |||||
| ;; End: | |||||
| @ -1,69 +0,0 @@ | |||||
| ;;; company-pysmell.el --- company-mode completion back-end for pysmell.el | |||||
| ;; Copyright (C) 2009-2011, 2013-2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;; The main problem with using this backend is installing Pysmell. | |||||
| ;; I couldn't manage to do that. --Dmitry | |||||
| ;;; Code: | |||||
| (if t (require 'pysmell)) ;Don't load during compilation. | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defvar-local company-pysmell--available-p 'unknown) | |||||
| (defun company-pysmell--available-p () | |||||
| (if (eq company-pysmell--available-p 'unknown) | |||||
| (setq company-pysmell--available-p | |||||
| (locate-dominating-file buffer-file-name "PYSMELLTAGS")) | |||||
| company-pysmell--available-p)) | |||||
| (defun company-pysmell--grab-symbol () | |||||
| (let ((symbol (company-grab-symbol))) | |||||
| (when symbol | |||||
| (cons symbol | |||||
| (save-excursion | |||||
| (let ((pos (point))) | |||||
| (goto-char (- (point) (length symbol))) | |||||
| (while (eq (char-before) ?.) | |||||
| (goto-char (1- (point))) | |||||
| (skip-syntax-backward "w_")) | |||||
| (- pos (point)))))))) | |||||
| ;;;###autoload | |||||
| (defun company-pysmell (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for pysmell. | |||||
| This requires pysmell.el and pymacs.el." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-pysmell)) | |||||
| (prefix (and (derived-mode-p 'python-mode) | |||||
| buffer-file-name | |||||
| (not (company-in-string-or-comment)) | |||||
| (company-pysmell--available-p) | |||||
| (company-pysmell--grab-symbol))) | |||||
| (candidates (delete "" (pysmell-get-all-completions))))) | |||||
| (provide 'company-pysmell) | |||||
| ;;; company-pysmell.el ends here | |||||
| @ -1,72 +0,0 @@ | |||||
| ;;; company-ropemacs.el --- company-mode completion back-end for ropemacs | |||||
| ;; Copyright (C) 2009-2011, 2013-2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'cl-lib) | |||||
| (defun company-ropemacs--grab-symbol () | |||||
| (let ((symbol (company-grab-symbol))) | |||||
| (when symbol | |||||
| (cons symbol | |||||
| (save-excursion | |||||
| (let ((pos (point))) | |||||
| (goto-char (- (point) (length symbol))) | |||||
| (while (eq (char-before) ?.) | |||||
| (goto-char (1- (point))) | |||||
| (skip-syntax-backward "w_")) | |||||
| (- pos (point)))))))) | |||||
| (defun company-ropemacs-doc-buffer (candidate) | |||||
| "Return buffer with docstring of CANDIDATE if it is available." | |||||
| (let ((doc (company-with-candidate-inserted candidate (rope-get-doc)))) | |||||
| (when doc | |||||
| (company-doc-buffer doc)))) | |||||
| (defun company-ropemacs-location (candidate) | |||||
| "Return location of CANDIDATE in cons form (FILE . LINE) if it is available." | |||||
| (let ((location (company-with-candidate-inserted candidate | |||||
| (rope-definition-location)))) | |||||
| (when location | |||||
| (cons (elt location 0) (elt location 1))))) | |||||
| (defun company-ropemacs (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for ropemacs. | |||||
| Depends on third-party code: Pymacs (both Python and Emacs packages), | |||||
| rope, ropemacs and ropemode. Requires `ropemacs-mode' to be on." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-ropemacs)) | |||||
| (prefix (and (bound-and-true-p ropemacs-mode) | |||||
| (not (company-in-string-or-comment)) | |||||
| (company-ropemacs--grab-symbol))) | |||||
| (candidates (mapcar (lambda (element) (concat arg element)) | |||||
| (rope-completions))) | |||||
| (doc-buffer (company-ropemacs-doc-buffer arg)) | |||||
| (location (company-ropemacs-location arg)))) | |||||
| (provide 'company-ropemacs) | |||||
| ;;; company-ropemacs.el ends here | |||||
| @ -1,146 +0,0 @@ | |||||
| ;;; company-semantic.el --- company-mode completion back-end using Semantic | |||||
| ;; Copyright (C) 2009-2011, 2013 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defvar semantic-idle-summary-function) | |||||
| (declare-function semantic-documentation-for-tag "semantic/doc" ) | |||||
| (declare-function semantic-analyze-current-context "semantic/analyze") | |||||
| (declare-function semantic-analyze-possible-completions "semantic/complete") | |||||
| (declare-function semantic-analyze-find-tags-by-prefix "semantic/analyze/fcn") | |||||
| (declare-function semantic-tag-class "semantic/tag") | |||||
| (declare-function semantic-tag-name "semantic/tag") | |||||
| (declare-function semantic-tag-start "semantic/tag") | |||||
| (declare-function semantic-tag-buffer "semantic/tag") | |||||
| (declare-function semantic-active-p "semantic") | |||||
| (defgroup company-semantic nil | |||||
| "Completion back-end using Semantic." | |||||
| :group 'company) | |||||
| (defcustom company-semantic-metadata-function 'company-semantic-summary-and-doc | |||||
| "The function turning a semantic tag into doc information." | |||||
| :type 'function) | |||||
| (defvar company-semantic-modes '(c-mode c++-mode jde-mode java-mode)) | |||||
| (defvar-local company-semantic--current-tags nil | |||||
| "Tags for the current context.") | |||||
| (defun company-semantic-documentation-for-tag (tag) | |||||
| (when (semantic-tag-buffer tag) | |||||
| ;; When TAG's buffer is unknown, the function below raises an error. | |||||
| (semantic-documentation-for-tag tag))) | |||||
| (defun company-semantic-doc-or-summary (tag) | |||||
| (or (company-semantic-documentation-for-tag tag) | |||||
| (and (require 'semantic-idle nil t) | |||||
| (require 'semantic/idle nil t) | |||||
| (funcall semantic-idle-summary-function tag nil t)))) | |||||
| (defun company-semantic-summary-and-doc (tag) | |||||
| (let ((doc (company-semantic-documentation-for-tag tag)) | |||||
| (summary (funcall semantic-idle-summary-function tag nil t))) | |||||
| (and (stringp doc) | |||||
| (string-match "\n*\\(.*\\)$" doc) | |||||
| (setq doc (match-string 1 doc))) | |||||
| (concat summary | |||||
| (when doc | |||||
| (if (< (+ (length doc) (length summary) 4) (window-width)) | |||||
| " -- " | |||||
| "\n")) | |||||
| doc))) | |||||
| (defun company-semantic-doc-buffer (tag) | |||||
| (let ((doc (company-semantic-documentation-for-tag tag))) | |||||
| (when doc | |||||
| (company-doc-buffer | |||||
| (concat (funcall semantic-idle-summary-function tag nil t) | |||||
| "\n" | |||||
| doc))))) | |||||
| (defsubst company-semantic-completions (prefix) | |||||
| (ignore-errors | |||||
| (let ((completion-ignore-case nil) | |||||
| (context (semantic-analyze-current-context))) | |||||
| (setq company-semantic--current-tags | |||||
| (semantic-analyze-possible-completions context)) | |||||
| (all-completions prefix company-semantic--current-tags)))) | |||||
| (defun company-semantic-completions-raw (prefix) | |||||
| (setq company-semantic--current-tags nil) | |||||
| (dolist (tag (semantic-analyze-find-tags-by-prefix prefix)) | |||||
| (unless (eq (semantic-tag-class tag) 'include) | |||||
| (push tag company-semantic--current-tags))) | |||||
| (delete "" (mapcar 'semantic-tag-name company-semantic--current-tags))) | |||||
| (defun company-semantic--pre-prefix-length (prefix-length) | |||||
| "Sum up the length of all chained symbols before POS. | |||||
| Symbols are chained by \".\" or \"->\"." | |||||
| (save-excursion | |||||
| (let ((pos (point))) | |||||
| (goto-char (- (point) prefix-length)) | |||||
| (while (looking-back "->\\|\\.") | |||||
| (goto-char (match-beginning 0)) | |||||
| (skip-syntax-backward "w_")) | |||||
| (- pos (point))))) | |||||
| (defun company-semantic--grab () | |||||
| "Grab the semantic prefix, but return everything before -> or . as length." | |||||
| (let ((symbol (company-grab-symbol))) | |||||
| (when symbol | |||||
| (cons symbol (company-semantic--pre-prefix-length (length symbol)))))) | |||||
| ;;;###autoload | |||||
| (defun company-semantic (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end using CEDET Semantic." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-semantic)) | |||||
| (prefix (and (featurep 'semantic) | |||||
| (semantic-active-p) | |||||
| (memq major-mode company-semantic-modes) | |||||
| (not (company-in-string-or-comment)) | |||||
| (or (company-semantic--grab) 'stop))) | |||||
| (candidates (if (and (equal arg "") | |||||
| (not (looking-back "->\\|\\."))) | |||||
| (company-semantic-completions-raw arg) | |||||
| (company-semantic-completions arg))) | |||||
| (meta (funcall company-semantic-metadata-function | |||||
| (assoc arg company-semantic--current-tags))) | |||||
| (doc-buffer (company-semantic-doc-buffer | |||||
| (assoc arg company-semantic--current-tags))) | |||||
| ;; Because "" is an empty context and doesn't return local variables. | |||||
| (no-cache (equal arg "")) | |||||
| (location (let ((tag (assoc arg company-semantic--current-tags))) | |||||
| (when (buffer-live-p (semantic-tag-buffer tag)) | |||||
| (cons (semantic-tag-buffer tag) | |||||
| (semantic-tag-start tag))))))) | |||||
| (provide 'company-semantic) | |||||
| ;;; company-semantic.el ends here | |||||
| @ -1,197 +0,0 @@ | |||||
| ;;; company-template.el | |||||
| ;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Code: | |||||
| (require 'cl-lib) | |||||
| (defface company-template-field | |||||
| '((((background dark)) (:background "yellow" :foreground "black")) | |||||
| (((background light)) (:background "orange" :foreground "black"))) | |||||
| "Face used for editable text in template fields." | |||||
| :group 'company) | |||||
| (defvar company-template-nav-map | |||||
| (let ((keymap (make-sparse-keymap))) | |||||
| (define-key keymap [tab] 'company-template-forward-field) | |||||
| (define-key keymap (kbd "TAB") 'company-template-forward-field) | |||||
| keymap)) | |||||
| (defvar-local company-template--buffer-templates nil) | |||||
| ;; interactive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-template-templates-at (pos) | |||||
| (let (os) | |||||
| (dolist (o (overlays-at pos)) | |||||
| ;; FIXME: Always return the whole list of templates? | |||||
| ;; We remove templates not at point after every command. | |||||
| (when (memq o company-template--buffer-templates) | |||||
| (push o os))) | |||||
| os)) | |||||
| (defun company-template-move-to-first (templ) | |||||
| (interactive) | |||||
| (goto-char (overlay-start templ)) | |||||
| (company-template-forward-field)) | |||||
| (defun company-template-forward-field () | |||||
| (interactive) | |||||
| (let* ((start (point)) | |||||
| (templates (company-template-templates-at (point))) | |||||
| (minimum (apply 'max (mapcar 'overlay-end templates))) | |||||
| (fields (cl-loop for templ in templates | |||||
| append (overlay-get templ 'company-template-fields)))) | |||||
| (dolist (pos (mapcar 'overlay-start fields)) | |||||
| (and pos | |||||
| (> pos (point)) | |||||
| (< pos minimum) | |||||
| (setq minimum pos))) | |||||
| (push-mark) | |||||
| (goto-char minimum) | |||||
| (company-template-remove-field (company-template-field-at start)))) | |||||
| (defun company-template-field-at (&optional point) | |||||
| (cl-loop for ovl in (overlays-at (or point (point))) | |||||
| when (overlay-get ovl 'company-template-parent) | |||||
| return ovl)) | |||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-template-declare-template (beg end) | |||||
| (let ((ov (make-overlay beg end))) | |||||
| ;; (overlay-put ov 'face 'highlight) | |||||
| (overlay-put ov 'keymap company-template-nav-map) | |||||
| (overlay-put ov 'priority 101) | |||||
| (overlay-put ov 'evaporate t) | |||||
| (push ov company-template--buffer-templates) | |||||
| (add-hook 'post-command-hook 'company-template-post-command nil t) | |||||
| ov)) | |||||
| (defun company-template-remove-template (templ) | |||||
| (mapc 'company-template-remove-field | |||||
| (overlay-get templ 'company-template-fields)) | |||||
| (setq company-template--buffer-templates | |||||
| (delq templ company-template--buffer-templates)) | |||||
| (delete-overlay templ)) | |||||
| (defun company-template-add-field (templ pos text &optional display) | |||||
| "Add new field to template TEMPL at POS, inserting TEXT. | |||||
| When DISPLAY is non-nil, set the respective property on the overlay. | |||||
| Leave point at the end of the field." | |||||
| (cl-assert templ) | |||||
| (goto-char pos) | |||||
| (insert text) | |||||
| (when (> (point) (overlay-end templ)) | |||||
| (move-overlay templ (overlay-start templ) (point))) | |||||
| (let ((ov (make-overlay pos (+ pos (length text)))) | |||||
| (siblings (overlay-get templ 'company-template-fields))) | |||||
| ;; (overlay-put ov 'evaporate t) | |||||
| (overlay-put ov 'intangible t) | |||||
| (overlay-put ov 'face 'company-template-field) | |||||
| (when display | |||||
| (overlay-put ov 'display display)) | |||||
| (overlay-put ov 'company-template-parent templ) | |||||
| (overlay-put ov 'insert-in-front-hooks '(company-template-insert-hook)) | |||||
| (push ov siblings) | |||||
| (overlay-put templ 'company-template-fields siblings))) | |||||
| (defun company-template-remove-field (ovl &optional clear) | |||||
| (when (overlayp ovl) | |||||
| (when (overlay-buffer ovl) | |||||
| (when clear | |||||
| (delete-region (overlay-start ovl) (overlay-end ovl))) | |||||
| (delete-overlay ovl)) | |||||
| (let* ((templ (overlay-get ovl 'company-template-parent)) | |||||
| (siblings (overlay-get templ 'company-template-fields))) | |||||
| (setq siblings (delq ovl siblings)) | |||||
| (overlay-put templ 'company-template-fields siblings)))) | |||||
| (defun company-template-clean-up (&optional pos) | |||||
| "Clean up all templates that don't contain POS." | |||||
| (let ((local-ovs (overlays-at (or pos (point))))) | |||||
| (dolist (templ company-template--buffer-templates) | |||||
| (unless (memq templ local-ovs) | |||||
| (company-template-remove-template templ))))) | |||||
| ;; hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-template-insert-hook (ovl after-p &rest _ignore) | |||||
| "Called when a snippet input prompt is modified." | |||||
| (unless after-p | |||||
| (company-template-remove-field ovl t))) | |||||
| (defun company-template-post-command () | |||||
| (company-template-clean-up) | |||||
| (unless company-template--buffer-templates | |||||
| (remove-hook 'post-command-hook 'company-template-post-command t))) | |||||
| ;; common ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-template-c-like-templatify (call) | |||||
| (let* ((end (point-marker)) | |||||
| (beg (- (point) (length call))) | |||||
| (cnt 0) | |||||
| (templ (company-template-declare-template beg end)) | |||||
| paren-open paren-close) | |||||
| (with-syntax-table (make-char-table 'syntax-table nil) | |||||
| (modify-syntax-entry ?\( "(") | |||||
| (modify-syntax-entry ?\) ")") | |||||
| (modify-syntax-entry ?< "(") | |||||
| (modify-syntax-entry ?> ")") | |||||
| (when (search-backward ")" beg t) | |||||
| (setq paren-close (point-marker)) | |||||
| (forward-char 1) | |||||
| (delete-region (point) end) | |||||
| (backward-sexp) | |||||
| (forward-char 1) | |||||
| (setq paren-open (point-marker))) | |||||
| (when (search-backward ">" beg t) | |||||
| (let ((angle-close (point-marker))) | |||||
| (forward-char 1) | |||||
| (backward-sexp) | |||||
| (forward-char) | |||||
| (setq cnt (company-template--c-like-args templ angle-close | |||||
| cnt)))) | |||||
| (when paren-open | |||||
| (goto-char paren-open) | |||||
| (company-template--c-like-args templ paren-close cnt))) | |||||
| (if (overlay-get templ 'company-template-fields) | |||||
| (company-template-move-to-first templ) | |||||
| (company-template-remove-template templ) | |||||
| (goto-char end)))) | |||||
| (defun company-template--c-like-args (templ end counter) | |||||
| (let ((last-pos (point))) | |||||
| (while (re-search-forward "\\([^,]+\\),?" end 'move) | |||||
| (when (zerop (car (parse-partial-sexp last-pos (point)))) | |||||
| (let ((sig (buffer-substring-no-properties last-pos (match-end 1)))) | |||||
| (save-excursion | |||||
| (company-template-add-field templ last-pos | |||||
| (format "arg%d" counter) sig) | |||||
| (delete-region (point) (+ (point) (length sig)))) | |||||
| (skip-chars-forward " ") | |||||
| (setq last-pos (point)) | |||||
| (cl-incf counter))))) | |||||
| counter) | |||||
| (provide 'company-template) | |||||
| ;;; company-template.el ends here | |||||
| @ -1,123 +0,0 @@ | |||||
| ;;; company-xcode.el --- company-mode completion back-end for Xcode projects | |||||
| ;; Copyright (C) 2009-2011 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-xcode nil | |||||
| "Completion back-end for Xcode projects." | |||||
| :group 'company) | |||||
| (defcustom company-xcode-xcodeindex-executable (executable-find "xcodeindex") | |||||
| "Location of xcodeindex executable." | |||||
| :type 'file) | |||||
| (defvar company-xcode-tags nil) | |||||
| (defun company-xcode-reset () | |||||
| "Reset the cached tags." | |||||
| (interactive) | |||||
| (setq company-xcode-tags nil)) | |||||
| (defcustom company-xcode-types | |||||
| '("Class" "Constant" "Enum" "Macro" "Modeled Class" "Structure" | |||||
| "Type" "Union" "Function") | |||||
| "The types of symbols offered by `company-xcode'. | |||||
| No context-enabled completion is available. Types like methods will be | |||||
| offered regardless of whether the class supports them. The defaults should be | |||||
| valid in most contexts." | |||||
| :set (lambda (variable value) | |||||
| (set variable value) | |||||
| (company-xcode-reset)) | |||||
| :type '(set (const "Category") (const "Class") (const "Class Method") | |||||
| (const "Class Variable") (const "Constant") (const "Enum") | |||||
| (const "Field") (const "Instance Method") | |||||
| (const "Instance Variable") (const "Macro") | |||||
| (const "Modeled Class") (const "Modeled Method") | |||||
| (const "Modeled Property") (const "Property") (const "Protocol") | |||||
| (const "Structure") (const "Type") (const "Union") | |||||
| (const "Variable") (const "Function"))) | |||||
| (defvar-local company-xcode-project 'unknown) | |||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-xcode-fetch (project-bundle) | |||||
| (setq project-bundle (directory-file-name project-bundle)) | |||||
| (message "Retrieving dump from %s..." project-bundle) | |||||
| (with-temp-buffer | |||||
| (let ((default-directory (file-name-directory project-bundle))) | |||||
| (call-process company-xcode-xcodeindex-executable nil (current-buffer) | |||||
| nil "dump" "-project" | |||||
| (file-name-nondirectory project-bundle) "-quiet") | |||||
| (goto-char (point-min)) | |||||
| (let ((regexp (concat "^\\([^\t\n]*\\)\t[^\t\n]*\t" | |||||
| (regexp-opt company-xcode-types) | |||||
| "\t[^\t\n]*\t[^\t\n]*")) | |||||
| candidates) | |||||
| (while (re-search-forward regexp nil t) | |||||
| (add-to-list 'candidates (match-string 1))) | |||||
| (message "Retrieving dump from %s...done" project-bundle) | |||||
| candidates)))) | |||||
| (defun company-xcode-find-project () | |||||
| (let ((dir (if buffer-file-name | |||||
| (file-name-directory buffer-file-name) | |||||
| (expand-file-name default-directory))) | |||||
| (prev-dir nil) | |||||
| file) | |||||
| (while (not (or file (equal dir prev-dir))) | |||||
| (setq file (car (directory-files dir t ".xcodeproj\\'" t)) | |||||
| prev-dir dir | |||||
| dir (file-name-directory (directory-file-name dir)))) | |||||
| file)) | |||||
| (defun company-xcode-tags () | |||||
| (when (eq company-xcode-project 'unknown) | |||||
| (setq company-xcode-project (company-xcode-find-project))) | |||||
| (when company-xcode-project | |||||
| (cdr (or (assoc company-xcode-project company-xcode-tags) | |||||
| (car (push (cons company-xcode-project | |||||
| (company-xcode-fetch company-xcode-project)) | |||||
| company-xcode-tags)))))) | |||||
| ;;;###autoload | |||||
| (defun company-xcode (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for Xcode projects." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-xcode)) | |||||
| (prefix (and company-xcode-xcodeindex-executable | |||||
| (company-xcode-tags) | |||||
| (not (company-in-string-or-comment)) | |||||
| (or (company-grab-symbol) 'stop))) | |||||
| (candidates (let ((completion-ignore-case nil)) | |||||
| (company-xcode-tags) | |||||
| (all-completions arg (company-xcode-tags)))))) | |||||
| (provide 'company-xcode) | |||||
| ;;; company-xcode.el ends here | |||||
| @ -0,0 +1,281 @@ | |||||
| ;;; company-autoloads.el --- automatically extracted autoloads | |||||
| ;; | |||||
| ;;; Code: | |||||
| (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) | |||||
| ;;;### (autoloads nil "company" "company.el" (21837 24216 0 0)) | |||||
| ;;; Generated autoloads from company.el | |||||
| (autoload 'company-mode "company" "\ | |||||
| \"complete anything\"; is an in-buffer completion framework. | |||||
| Completion starts automatically, depending on the values | |||||
| `company-idle-delay' and `company-minimum-prefix-length'. | |||||
| Completion can be controlled with the commands: | |||||
| `company-complete-common', `company-complete-selection', `company-complete', | |||||
| `company-select-next', `company-select-previous'. If these commands are | |||||
| called before `company-idle-delay', completion will also start. | |||||
| Completions can be searched with `company-search-candidates' or | |||||
| `company-filter-candidates'. These can be used while completion is | |||||
| inactive, as well. | |||||
| The completion data is retrieved using `company-backends' and displayed | |||||
| using `company-frontends'. If you want to start a specific back-end, call | |||||
| it interactively or use `company-begin-backend'. | |||||
| regular keymap (`company-mode-map'): | |||||
| \\{company-mode-map} | |||||
| keymap during active completions (`company-active-map'): | |||||
| \\{company-active-map} | |||||
| \(fn &optional ARG)" t nil) | |||||
| (defvar global-company-mode nil "\ | |||||
| Non-nil if Global-Company mode is enabled. | |||||
| See the command `global-company-mode' for a description of this minor mode. | |||||
| Setting this variable directly does not take effect; | |||||
| either customize it (see the info node `Easy Customization') | |||||
| or call the function `global-company-mode'.") | |||||
| (custom-autoload 'global-company-mode "company" nil) | |||||
| (autoload 'global-company-mode "company" "\ | |||||
| Toggle Company mode in all buffers. | |||||
| With prefix ARG, enable Global-Company mode if ARG is positive; | |||||
| otherwise, disable it. If called from Lisp, enable the mode if | |||||
| ARG is omitted or nil. | |||||
| Company mode is enabled in all buffers where | |||||
| `company-mode-on' would do it. | |||||
| See `company-mode' for more information on Company mode. | |||||
| \(fn &optional ARG)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-abbrev" "company-abbrev.el" (21837 | |||||
| ;;;;;; 24216 0 0)) | |||||
| ;;; Generated autoloads from company-abbrev.el | |||||
| (autoload 'company-abbrev "company-abbrev" "\ | |||||
| `company-mode' completion back-end for abbrev. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-bbdb" "company-bbdb.el" (21837 24216 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-bbdb.el | |||||
| (autoload 'company-bbdb "company-bbdb" "\ | |||||
| `company-mode' completion back-end for BBDB. | |||||
| \(fn COMMAND &optional ARG &rest IGNORE)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-css" "company-css.el" (21837 24216 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-css.el | |||||
| (autoload 'company-css "company-css" "\ | |||||
| `company-mode' completion back-end for `css-mode'. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-dabbrev" "company-dabbrev.el" (21837 | |||||
| ;;;;;; 24216 0 0)) | |||||
| ;;; Generated autoloads from company-dabbrev.el | |||||
| (autoload 'company-dabbrev "company-dabbrev" "\ | |||||
| dabbrev-like `company-mode' completion back-end. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-dabbrev-code" "company-dabbrev-code.el" | |||||
| ;;;;;; (21837 24216 0 0)) | |||||
| ;;; Generated autoloads from company-dabbrev-code.el | |||||
| (autoload 'company-dabbrev-code "company-dabbrev-code" "\ | |||||
| dabbrev-like `company-mode' back-end for code. | |||||
| The back-end looks for all symbols in the current buffer that aren't in | |||||
| comments or strings. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-elisp" "company-elisp.el" (21837 24216 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-elisp.el | |||||
| (autoload 'company-elisp "company-elisp" "\ | |||||
| `company-mode' completion back-end for Emacs Lisp. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-etags" "company-etags.el" (21837 24216 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-etags.el | |||||
| (autoload 'company-etags "company-etags" "\ | |||||
| `company-mode' completion back-end for etags. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-files" "company-files.el" (21837 24216 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-files.el | |||||
| (autoload 'company-files "company-files" "\ | |||||
| `company-mode' completion back-end existing file names. | |||||
| Completions works for proper absolute and relative files paths. | |||||
| File paths with spaces are only supported inside strings. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-gtags" "company-gtags.el" (21837 24216 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-gtags.el | |||||
| (autoload 'company-gtags "company-gtags" "\ | |||||
| `company-mode' completion back-end for GNU Global. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-ispell" "company-ispell.el" (21837 | |||||
| ;;;;;; 24216 0 0)) | |||||
| ;;; Generated autoloads from company-ispell.el | |||||
| (autoload 'company-ispell "company-ispell" "\ | |||||
| `company-mode' completion back-end using Ispell. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-keywords" "company-keywords.el" (21837 | |||||
| ;;;;;; 24216 0 0)) | |||||
| ;;; Generated autoloads from company-keywords.el | |||||
| (autoload 'company-keywords "company-keywords" "\ | |||||
| `company-mode' back-end for programming language keywords. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-nxml" "company-nxml.el" (21837 24216 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-nxml.el | |||||
| (autoload 'company-nxml "company-nxml" "\ | |||||
| `company-mode' completion back-end for `nxml-mode'. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-oddmuse" "company-oddmuse.el" (21837 | |||||
| ;;;;;; 24216 0 0)) | |||||
| ;;; Generated autoloads from company-oddmuse.el | |||||
| (autoload 'company-oddmuse "company-oddmuse" "\ | |||||
| `company-mode' completion back-end for `oddmuse-mode'. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-semantic" "company-semantic.el" (21837 | |||||
| ;;;;;; 24216 0 0)) | |||||
| ;;; Generated autoloads from company-semantic.el | |||||
| (autoload 'company-semantic "company-semantic" "\ | |||||
| `company-mode' completion back-end using CEDET Semantic. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-tempo" "company-tempo.el" (21837 24216 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-tempo.el | |||||
| (autoload 'company-tempo "company-tempo" "\ | |||||
| `company-mode' completion back-end for tempo. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-xcode" "company-xcode.el" (21837 24216 | |||||
| ;;;;;; 0 0)) | |||||
| ;;; Generated autoloads from company-xcode.el | |||||
| (autoload 'company-xcode "company-xcode" "\ | |||||
| `company-mode' completion back-end for Xcode projects. | |||||
| \(fn COMMAND &optional ARG &rest IGNORED)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil "company-yasnippet" "company-yasnippet.el" | |||||
| ;;;;;; (21837 24216 0 0)) | |||||
| ;;; Generated autoloads from company-yasnippet.el | |||||
| (autoload 'company-yasnippet "company-yasnippet" "\ | |||||
| `company-mode' back-end for `yasnippet'. | |||||
| This back-end should be used with care, because as long as there are | |||||
| snippets defined for the current major mode, this back-end will always | |||||
| shadow back-ends that come after it. Recommended usages: | |||||
| * In a buffer-local value of `company-backends', grouped with a back-end or | |||||
| several that provide actual text completions. | |||||
| (add-hook 'js-mode-hook | |||||
| (lambda () | |||||
| (set (make-local-variable 'company-backends) | |||||
| '((company-dabbrev-code company-yasnippet))))) | |||||
| * After keyword `:with', grouped with other back-ends. | |||||
| (push '(company-semantic :with company-yasnippet) company-backends) | |||||
| * Not in `company-backends', just bound to a key. | |||||
| (global-set-key (kbd \"C-c y\") 'company-yasnippet) | |||||
| \(fn COMMAND &optional ARG &rest IGNORE)" t nil) | |||||
| ;;;*** | |||||
| ;;;### (autoloads nil nil ("company-capf.el" "company-clang.el" "company-cmake.el" | |||||
| ;;;;;; "company-eclim.el" "company-pkg.el" "company-template.el") | |||||
| ;;;;;; (21837 24216 843840 0)) | |||||
| ;;;*** | |||||
| ;; Local Variables: | |||||
| ;; version-control: never | |||||
| ;; no-byte-compile: t | |||||
| ;; no-update-autoloads: t | |||||
| ;; End: | |||||
| ;;; company-autoloads.el ends here | |||||
| @ -0,0 +1,61 @@ | |||||
| ;;; company-bbdb.el --- company-mode completion back-end for BBDB in message-mode | |||||
| ;; Copyright (C) 2013-2014 Free Software Foundation, Inc. | |||||
| ;; Author: Jan Tatarik <jan.tatarik@gmail.com> | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (declare-function bbdb-record-get-field "bbdb") | |||||
| (declare-function bbdb-records "bbdb") | |||||
| (declare-function bbdb-dwim-mail "bbdb-com") | |||||
| (declare-function bbdb-search "bbdb-com") | |||||
| (defgroup company-bbdb nil | |||||
| "Completion back-end for BBDB." | |||||
| :group 'company) | |||||
| (defcustom company-bbdb-modes '(message-mode) | |||||
| "Major modes in which `company-bbdb' may complete." | |||||
| :type '(repeat (symbol :tag "Major mode")) | |||||
| :package-version '(company . "0.8.8")) | |||||
| (defun company-bbdb--candidates (arg) | |||||
| (cl-mapcan (lambda (record) | |||||
| (mapcar (lambda (mail) (bbdb-dwim-mail record mail)) | |||||
| (bbdb-record-get-field record 'mail))) | |||||
| (eval '(bbdb-search (bbdb-records) arg nil arg)))) | |||||
| ;;;###autoload | |||||
| (defun company-bbdb (command &optional arg &rest ignore) | |||||
| "`company-mode' completion back-end for BBDB." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-bbdb)) | |||||
| (prefix (and (memq major-mode company-bbdb-modes) | |||||
| (featurep 'bbdb-com) | |||||
| (looking-back "^\\(To\\|Cc\\|Bcc\\): *\\(.*\\)" | |||||
| (line-beginning-position)) | |||||
| (match-string-no-properties 2))) | |||||
| (candidates (company-bbdb--candidates arg)) | |||||
| (sorted t) | |||||
| (no-cache t))) | |||||
| (provide 'company-bbdb) | |||||
| ;;; company-bbdb.el ends here | |||||
| @ -0,0 +1,153 @@ | |||||
| ;;; company-capf.el --- company-mode completion-at-point-functions back-end -*- lexical-binding: t -*- | |||||
| ;; Copyright (C) 2013-2015 Free Software Foundation, Inc. | |||||
| ;; Author: Stefan Monnier <monnier@iro.umontreal.ca> | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defvar company--capf-cache nil) | |||||
| (defun company--capf-data () | |||||
| (let ((cache company--capf-cache)) | |||||
| (if (and (equal (current-buffer) (car cache)) | |||||
| (equal (point) (car (setq cache (cdr cache)))) | |||||
| (equal (buffer-chars-modified-tick) (car (setq cache (cdr cache))))) | |||||
| (cadr cache) | |||||
| (let ((data (company--capf-data-real))) | |||||
| (setq company--capf-cache | |||||
| (list (current-buffer) (point) (buffer-chars-modified-tick) data)) | |||||
| data)))) | |||||
| (defun company--capf-data-real () | |||||
| (cl-letf* (((default-value 'completion-at-point-functions) | |||||
| ;; Ignore tags-completion-at-point-function because it subverts | |||||
| ;; company-etags in the default value of company-backends, where | |||||
| ;; the latter comes later. | |||||
| (remove 'tags-completion-at-point-function | |||||
| (default-value 'completion-at-point-functions))) | |||||
| (data (run-hook-wrapped 'completion-at-point-functions | |||||
| ;; Ignore misbehaving functions. | |||||
| #'completion--capf-wrapper 'optimist))) | |||||
| (when (and (consp (cdr data)) (integer-or-marker-p (nth 1 data))) data))) | |||||
| (defun company-capf (command &optional arg &rest _args) | |||||
| "`company-mode' back-end using `completion-at-point-functions'." | |||||
| (interactive (list 'interactive)) | |||||
| (pcase command | |||||
| (`interactive (company-begin-backend 'company-capf)) | |||||
| (`prefix | |||||
| (let ((res (company--capf-data))) | |||||
| (when res | |||||
| (if (> (nth 2 res) (point)) | |||||
| 'stop | |||||
| (buffer-substring-no-properties (nth 1 res) (point)))))) | |||||
| (`candidates | |||||
| (let ((res (company--capf-data))) | |||||
| (when res | |||||
| (let* ((table (nth 3 res)) | |||||
| (pred (plist-get (nthcdr 4 res) :predicate)) | |||||
| (meta (completion-metadata | |||||
| (buffer-substring (nth 1 res) (nth 2 res)) | |||||
| table pred)) | |||||
| (sortfun (cdr (assq 'display-sort-function meta))) | |||||
| (candidates (completion-all-completions arg table pred (length arg))) | |||||
| (last (last candidates)) | |||||
| (base-size (and (numberp (cdr last)) (cdr last)))) | |||||
| (when base-size | |||||
| (setcdr last nil)) | |||||
| (when sortfun | |||||
| (setq candidates (funcall sortfun candidates))) | |||||
| (if (not (zerop (or base-size 0))) | |||||
| (let ((before (substring arg 0 base-size))) | |||||
| (mapcar (lambda (candidate) | |||||
| (concat before candidate)) | |||||
| candidates)) | |||||
| candidates))))) | |||||
| (`sorted | |||||
| (let ((res (company--capf-data))) | |||||
| (when res | |||||
| (let ((meta (completion-metadata | |||||
| (buffer-substring (nth 1 res) (nth 2 res)) | |||||
| (nth 3 res) (plist-get (nthcdr 4 res) :predicate)))) | |||||
| (cdr (assq 'display-sort-function meta)))))) | |||||
| (`match | |||||
| ;; Can't just use 0 when base-size (see above) is non-zero. | |||||
| (let ((start (if (get-text-property 0 'font-lock-face arg) | |||||
| 0 | |||||
| (next-single-property-change 0 'font-lock-face arg)))) | |||||
| (when start | |||||
| ;; completions-common-part comes first, but we can't just look for this | |||||
| ;; value because it can be in a list. | |||||
| (or | |||||
| (let ((value (get-text-property start 'font-lock-face arg))) | |||||
| (text-property-not-all start (length arg) | |||||
| 'font-lock-face value arg)) | |||||
| (length arg))))) | |||||
| (`duplicates t) | |||||
| (`no-cache t) ;Not much can be done here, as long as we handle | |||||
| ;non-prefix matches. | |||||
| (`meta | |||||
| (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-docsig))) | |||||
| (when f (funcall f arg)))) | |||||
| (`doc-buffer | |||||
| (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-doc-buffer))) | |||||
| (when f (funcall f arg)))) | |||||
| (`location | |||||
| (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-location))) | |||||
| (when f (funcall f arg)))) | |||||
| (`annotation | |||||
| (save-excursion | |||||
| ;; FIXME: `company-begin' sets `company-point' after calling | |||||
| ;; `company--begin-new'. We shouldn't rely on `company-point' here, | |||||
| ;; better to cache the capf-data value instead. However: we can't just | |||||
| ;; save the last capf-data value in `prefix', because that command can | |||||
| ;; get called more often than `candidates', and at any point in the | |||||
| ;; buffer (https://github.com/company-mode/company-mode/issues/153). | |||||
| ;; We could try propertizing the returned prefix string, but it's not | |||||
| ;; passed to `annotation', and `company-prefix' is set only after | |||||
| ;; `company--strip-duplicates' is called. | |||||
| (when company-point | |||||
| (goto-char company-point)) | |||||
| (let ((f (plist-get (nthcdr 4 (company--capf-data)) :annotation-function))) | |||||
| (when f (funcall f arg))))) | |||||
| (`require-match | |||||
| (plist-get (nthcdr 4 (company--capf-data)) :company-require-match)) | |||||
| (`init nil) ;Don't bother: plenty of other ways to initialize the code. | |||||
| (`post-completion | |||||
| (let* ((res (company--capf-data)) | |||||
| (exit-function (plist-get (nthcdr 4 res) :exit-function)) | |||||
| (table (nth 3 res)) | |||||
| (pred (plist-get (nthcdr 4 res) :predicate))) | |||||
| (if exit-function | |||||
| ;; Follow the example of `completion--done'. | |||||
| (funcall exit-function arg | |||||
| (if (eq (try-completion arg table pred) t) | |||||
| 'finished 'sole))))) | |||||
| )) | |||||
| (provide 'company-capf) | |||||
| ;;; company-capf.el ends here | |||||
| @ -0,0 +1,331 @@ | |||||
| ;;; company-clang.el --- company-mode completion back-end for Clang -*- lexical-binding: t -*- | |||||
| ;; Copyright (C) 2009, 2011, 2013-2015 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'company-template) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-clang nil | |||||
| "Completion back-end for Clang." | |||||
| :group 'company) | |||||
| (defcustom company-clang-executable | |||||
| (executable-find "clang") | |||||
| "Location of clang executable." | |||||
| :type 'file) | |||||
| (defcustom company-clang-begin-after-member-access t | |||||
| "When non-nil, automatic completion will start whenever the current | |||||
| symbol is preceded by \".\", \"->\" or \"::\", ignoring | |||||
| `company-minimum-prefix-length'. | |||||
| If `company-begin-commands' is a list, it should include `c-electric-lt-gt' | |||||
| and `c-electric-colon', for automatic completion right after \">\" and | |||||
| \":\".") | |||||
| (defcustom company-clang-arguments nil | |||||
| "Additional arguments to pass to clang when completing. | |||||
| Prefix files (-include ...) can be selected with `company-clang-set-prefix' | |||||
| or automatically through a custom `company-clang-prefix-guesser'." | |||||
| :type '(repeat (string :tag "Argument"))) | |||||
| (defcustom company-clang-prefix-guesser 'company-clang-guess-prefix | |||||
| "A function to determine the prefix file for the current buffer." | |||||
| :type '(function :tag "Guesser function" nil)) | |||||
| (defvar company-clang-modes '(c-mode c++-mode objc-mode) | |||||
| "Major modes which clang may complete.") | |||||
| (defcustom company-clang-insert-arguments t | |||||
| "When non-nil, insert function arguments as a template after completion." | |||||
| :type 'boolean | |||||
| :package-version '(company . "0.8.0")) | |||||
| ;; prefix ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defvar company-clang--prefix nil) | |||||
| (defsubst company-clang--guess-pch-file (file) | |||||
| (let ((dir (directory-file-name (file-name-directory file)))) | |||||
| (when (equal (file-name-nondirectory dir) "Classes") | |||||
| (setq dir (file-name-directory dir))) | |||||
| (car (directory-files dir t "\\([^.]h\\|[^h]\\).pch\\'" t)))) | |||||
| (defsubst company-clang--file-substring (file beg end) | |||||
| (with-temp-buffer | |||||
| (insert-file-contents-literally file nil beg end) | |||||
| (buffer-string))) | |||||
| (defun company-clang-guess-prefix () | |||||
| "Try to guess the prefix file for the current buffer." | |||||
| ;; Prefixes seem to be called .pch. Pre-compiled headers do, too. | |||||
| ;; So we look at the magic number to rule them out. | |||||
| (let* ((file (company-clang--guess-pch-file buffer-file-name)) | |||||
| (magic-number (and file (company-clang--file-substring file 0 4)))) | |||||
| (unless (member magic-number '("CPCH" "gpch")) | |||||
| file))) | |||||
| (defun company-clang-set-prefix (&optional prefix) | |||||
| "Use PREFIX as a prefix (-include ...) file for clang completion." | |||||
| (interactive (let ((def (funcall company-clang-prefix-guesser))) | |||||
| (unless (stringp def) | |||||
| (setq def default-directory)) | |||||
| (list (read-file-name "Prefix file: " | |||||
| (when def (file-name-directory def)) | |||||
| def t (when def (file-name-nondirectory def)))))) | |||||
| ;; TODO: pre-compile? | |||||
| (setq company-clang--prefix (and (stringp prefix) | |||||
| (file-regular-p prefix) | |||||
| prefix))) | |||||
| ;; Clean-up on exit. | |||||
| (add-hook 'kill-emacs-hook 'company-clang-set-prefix) | |||||
| ;; parsing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| ;; TODO: Handle Pattern (syntactic hints would be neat). | |||||
| ;; Do we ever see OVERLOAD (or OVERRIDE)? | |||||
| (defconst company-clang--completion-pattern | |||||
| "^COMPLETION: \\_<\\(%s[a-zA-Z0-9_:]*\\)\\(?: : \\(.*\\)$\\)?$") | |||||
| (defconst company-clang--error-buffer-name "*clang-error*") | |||||
| (defun company-clang--lang-option () | |||||
| (if (eq major-mode 'objc-mode) | |||||
| (if (string= "m" (file-name-extension buffer-file-name)) | |||||
| "objective-c" "objective-c++") | |||||
| (substring (symbol-name major-mode) 0 -5))) | |||||
| (defun company-clang--parse-output (prefix _objc) | |||||
| (goto-char (point-min)) | |||||
| (let ((pattern (format company-clang--completion-pattern | |||||
| (regexp-quote prefix))) | |||||
| (case-fold-search nil) | |||||
| lines match) | |||||
| (while (re-search-forward pattern nil t) | |||||
| (setq match (match-string-no-properties 1)) | |||||
| (unless (equal match "Pattern") | |||||
| (save-match-data | |||||
| (when (string-match ":" match) | |||||
| (setq match (substring match 0 (match-beginning 0))))) | |||||
| (let ((meta (match-string-no-properties 2))) | |||||
| (when (and meta (not (string= match meta))) | |||||
| (put-text-property 0 1 'meta | |||||
| (company-clang--strip-formatting meta) | |||||
| match))) | |||||
| (push match lines))) | |||||
| lines)) | |||||
| (defun company-clang--meta (candidate) | |||||
| (get-text-property 0 'meta candidate)) | |||||
| (defun company-clang--annotation (candidate) | |||||
| (let ((ann (company-clang--annotation-1 candidate))) | |||||
| (if (not (and ann (string-prefix-p "(*)" ann))) | |||||
| ann | |||||
| (with-temp-buffer | |||||
| (insert ann) | |||||
| (search-backward ")") | |||||
| (let ((pt (1+ (point)))) | |||||
| (re-search-forward ".\\_>" nil t) | |||||
| (delete-region pt (point))) | |||||
| (buffer-string))))) | |||||
| (defun company-clang--annotation-1 (candidate) | |||||
| (let ((meta (company-clang--meta candidate))) | |||||
| (cond | |||||
| ((null meta) nil) | |||||
| ((string-match "[^:]:[^:]" meta) | |||||
| (substring meta (1+ (match-beginning 0)))) | |||||
| ((string-match "\\((.*)[ a-z]*\\'\\)" meta) | |||||
| (let ((paren (match-beginning 1))) | |||||
| (if (not (eq (aref meta (1- paren)) ?>)) | |||||
| (match-string 1 meta) | |||||
| (with-temp-buffer | |||||
| (insert meta) | |||||
| (goto-char paren) | |||||
| (substring meta (1- (search-backward "<")))))))))) | |||||
| (defun company-clang--strip-formatting (text) | |||||
| (replace-regexp-in-string | |||||
| "#]" " " | |||||
| (replace-regexp-in-string "[<{[]#\\|#[>}]" "" text t) | |||||
| t)) | |||||
| (defun company-clang--handle-error (res args) | |||||
| (goto-char (point-min)) | |||||
| (let* ((buf (get-buffer-create company-clang--error-buffer-name)) | |||||
| (cmd (concat company-clang-executable " " (mapconcat 'identity args " "))) | |||||
| (pattern (format company-clang--completion-pattern "")) | |||||
| (err (if (re-search-forward pattern nil t) | |||||
| (buffer-substring-no-properties (point-min) | |||||
| (1- (match-beginning 0))) | |||||
| ;; Warn the user more aggressively if no match was found. | |||||
| (message "clang failed with error %d:\n%s" res cmd) | |||||
| (buffer-string)))) | |||||
| (with-current-buffer buf | |||||
| (let ((inhibit-read-only t)) | |||||
| (erase-buffer) | |||||
| (insert (current-time-string) | |||||
| (format "\nclang failed with error %d:\n" res) | |||||
| cmd "\n\n") | |||||
| (insert err) | |||||
| (setq buffer-read-only t) | |||||
| (goto-char (point-min)))))) | |||||
| (defun company-clang--start-process (prefix callback &rest args) | |||||
| (let ((objc (derived-mode-p 'objc-mode)) | |||||
| (buf (get-buffer-create "*clang-output*")) | |||||
| ;; Looks unnecessary in Emacs 25.1 and later. | |||||
| (process-adaptive-read-buffering nil)) | |||||
| (with-current-buffer buf | |||||
| (erase-buffer) | |||||
| (setq buffer-undo-list t)) | |||||
| (if (get-buffer-process buf) | |||||
| (funcall callback nil) | |||||
| (let ((process (apply #'start-process "company-clang" buf | |||||
| company-clang-executable args))) | |||||
| (set-process-sentinel | |||||
| process | |||||
| (lambda (proc status) | |||||
| (unless (string-match-p "hangup" status) | |||||
| (funcall | |||||
| callback | |||||
| (let ((res (process-exit-status proc))) | |||||
| (with-current-buffer buf | |||||
| (unless (eq 0 res) | |||||
| (company-clang--handle-error res args)) | |||||
| ;; Still try to get any useful input. | |||||
| (company-clang--parse-output prefix objc))))))) | |||||
| (unless (company-clang--auto-save-p) | |||||
| (send-region process (point-min) (point-max)) | |||||
| (send-string process "\n") | |||||
| (process-send-eof process)))))) | |||||
| (defsubst company-clang--build-location (pos) | |||||
| (save-excursion | |||||
| (goto-char pos) | |||||
| (format "%s:%d:%d" | |||||
| (if (company-clang--auto-save-p) buffer-file-name "-") | |||||
| (line-number-at-pos) | |||||
| (1+ (length | |||||
| (encode-coding-region | |||||
| (line-beginning-position) | |||||
| (point) | |||||
| 'utf-8 | |||||
| t)))))) | |||||
| (defsubst company-clang--build-complete-args (pos) | |||||
| (append '("-fsyntax-only" "-Xclang" "-code-completion-macros") | |||||
| (unless (company-clang--auto-save-p) | |||||
| (list "-x" (company-clang--lang-option))) | |||||
| company-clang-arguments | |||||
| (when (stringp company-clang--prefix) | |||||
| (list "-include" (expand-file-name company-clang--prefix))) | |||||
| (list "-Xclang" (format "-code-completion-at=%s" | |||||
| (company-clang--build-location pos))) | |||||
| (list (if (company-clang--auto-save-p) buffer-file-name "-")))) | |||||
| (defun company-clang--candidates (prefix callback) | |||||
| (and (company-clang--auto-save-p) | |||||
| (buffer-modified-p) | |||||
| (basic-save-buffer)) | |||||
| (when (null company-clang--prefix) | |||||
| (company-clang-set-prefix (or (funcall company-clang-prefix-guesser) | |||||
| 'none))) | |||||
| (apply 'company-clang--start-process | |||||
| prefix | |||||
| callback | |||||
| (company-clang--build-complete-args (- (point) (length prefix))))) | |||||
| (defun company-clang--prefix () | |||||
| (if company-clang-begin-after-member-access | |||||
| (company-grab-symbol-cons "\\.\\|->\\|::" 2) | |||||
| (company-grab-symbol))) | |||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defconst company-clang-required-version 1.1) | |||||
| (defvar company-clang--version nil) | |||||
| (defun company-clang--auto-save-p () | |||||
| (< company-clang--version 2.9)) | |||||
| (defsubst company-clang-version () | |||||
| "Return the version of `company-clang-executable'." | |||||
| (with-temp-buffer | |||||
| (call-process company-clang-executable nil t nil "--version") | |||||
| (goto-char (point-min)) | |||||
| (if (re-search-forward "clang\\(?: version \\|-\\)\\([0-9.]+\\)" nil t) | |||||
| (let ((ver (string-to-number (match-string-no-properties 1)))) | |||||
| (if (> ver 100) | |||||
| (/ ver 100) | |||||
| ver)) | |||||
| 0))) | |||||
| (defun company-clang (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for Clang. | |||||
| Clang is a parser for C and ObjC. Clang version 1.1 or newer is required. | |||||
| Additional command line arguments can be specified in | |||||
| `company-clang-arguments'. Prefix files (-include ...) can be selected | |||||
| with `company-clang-set-prefix' or automatically through a custom | |||||
| `company-clang-prefix-guesser'. | |||||
| With Clang versions before 2.9, we have to save the buffer before | |||||
| performing completion. With Clang 2.9 and later, buffer contents are | |||||
| passed via standard input." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-clang)) | |||||
| (init (when (memq major-mode company-clang-modes) | |||||
| (unless company-clang-executable | |||||
| (error "Company found no clang executable")) | |||||
| (setq company-clang--version (company-clang-version)) | |||||
| (when (< company-clang--version company-clang-required-version) | |||||
| (error "Company requires clang version 1.1")))) | |||||
| (prefix (and (memq major-mode company-clang-modes) | |||||
| buffer-file-name | |||||
| company-clang-executable | |||||
| (not (company-in-string-or-comment)) | |||||
| (or (company-clang--prefix) 'stop))) | |||||
| (candidates (cons :async | |||||
| (lambda (cb) (company-clang--candidates arg cb)))) | |||||
| (meta (company-clang--meta arg)) | |||||
| (annotation (company-clang--annotation arg)) | |||||
| (post-completion (let ((anno (company-clang--annotation arg))) | |||||
| (when (and company-clang-insert-arguments anno) | |||||
| (insert anno) | |||||
| (if (string-match "\\`:[^:]" anno) | |||||
| (company-clang-objc-templatify anno) | |||||
| (company-template-c-like-templatify | |||||
| (concat arg anno)))))))) | |||||
| (provide 'company-clang) | |||||
| ;;; company-clang.el ends here | |||||
| @ -0,0 +1,198 @@ | |||||
| ;;; company-cmake.el --- company-mode completion back-end for CMake | |||||
| ;; Copyright (C) 2013-2014 Free Software Foundation, Inc. | |||||
| ;; Author: Chen Bin <chenbin DOT sh AT gmail> | |||||
| ;; Version: 0.2 | |||||
| ;; This program is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; This program is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;; company-cmake offers completions for module names, variable names and | |||||
| ;; commands used by CMake. And their descriptions. | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-cmake nil | |||||
| "Completion back-end for CMake." | |||||
| :group 'company) | |||||
| (defcustom company-cmake-executable | |||||
| (executable-find "cmake") | |||||
| "Location of cmake executable." | |||||
| :type 'file) | |||||
| (defvar company-cmake-executable-arguments | |||||
| '("--help-command-list" | |||||
| "--help-module-list" | |||||
| "--help-variable-list") | |||||
| "The arguments we pass to cmake, separately. | |||||
| They affect which types of symbols we get completion candidates for.") | |||||
| (defvar company-cmake--completion-pattern | |||||
| "^\\(%s[a-zA-Z0-9_<>]%s\\)$" | |||||
| "Regexp to match the candidates.") | |||||
| (defvar company-cmake-modes '(cmake-mode) | |||||
| "Major modes in which cmake may complete.") | |||||
| (defvar company-cmake--candidates-cache nil | |||||
| "Cache for the raw candidates.") | |||||
| (defvar company-cmake--meta-command-cache nil | |||||
| "Cache for command arguments to retrieve descriptions for the candidates.") | |||||
| (defun company-cmake--replace-tags (rlt) | |||||
| (setq rlt (replace-regexp-in-string | |||||
| "\\(.*?\\(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" | |||||
| "\\1RELWITHDEBINFO\\2" "\\1MINSIZEREL\\2") | |||||
| "\n") | |||||
| rlt)) | |||||
| rlt) | |||||
| (defun company-cmake--fill-candidates-cache (arg) | |||||
| "Fill candidates cache if needed." | |||||
| (let (rlt) | |||||
| (unless company-cmake--candidates-cache | |||||
| (setq company-cmake--candidates-cache (make-hash-table :test 'equal))) | |||||
| ;; If hash is empty, fill it. | |||||
| (unless (gethash arg company-cmake--candidates-cache) | |||||
| (with-temp-buffer | |||||
| (let ((res (call-process company-cmake-executable nil t nil arg))) | |||||
| (unless (zerop res) | |||||
| (message "cmake executable exited with error=%d" res))) | |||||
| (setq rlt (buffer-string))) | |||||
| (setq rlt (company-cmake--replace-tags rlt)) | |||||
| (puthash arg rlt company-cmake--candidates-cache)) | |||||
| )) | |||||
| (defun company-cmake--parse (prefix content cmd) | |||||
| (let ((start 0) | |||||
| (pattern (format company-cmake--completion-pattern | |||||
| (regexp-quote prefix) | |||||
| (if (zerop (length prefix)) "+" "*"))) | |||||
| (lines (split-string content "\n")) | |||||
| match | |||||
| rlt) | |||||
| (dolist (line lines) | |||||
| (when (string-match pattern line) | |||||
| (let ((match (match-string 1 line))) | |||||
| (when match | |||||
| (puthash match cmd company-cmake--meta-command-cache) | |||||
| (push match rlt))))) | |||||
| rlt)) | |||||
| (defun company-cmake--candidates (prefix) | |||||
| (let (results | |||||
| cmd-opts | |||||
| str) | |||||
| (unless company-cmake--meta-command-cache | |||||
| (setq company-cmake--meta-command-cache (make-hash-table :test 'equal))) | |||||
| (dolist (arg company-cmake-executable-arguments) | |||||
| (company-cmake--fill-candidates-cache arg) | |||||
| (setq cmd-opts (replace-regexp-in-string "-list$" "" arg) ) | |||||
| (setq str (gethash arg company-cmake--candidates-cache)) | |||||
| (when str | |||||
| (setq results (nconc results | |||||
| (company-cmake--parse prefix str cmd-opts))))) | |||||
| results)) | |||||
| (defun company-cmake--unexpand-candidate (candidate) | |||||
| (cond | |||||
| ((string-match "^CMAKE_\\(C\\|CXX\\|Fortran\\)\\(_.*\\)$" candidate) | |||||
| (setq candidate (concat "CMAKE_<LANG>" (match-string 2 candidate)))) | |||||
| ;; C flags | |||||
| ((string-match "^\\(.*_\\)IS_GNU\\(C\\|CXX\\|G77\\)$" candidate) | |||||
| (setq candidate (concat (match-string 1 candidate) "IS_GNU<LANG>"))) | |||||
| ;; C flags | |||||
| ((string-match "^\\(.*_\\)OVERRIDE_\\(C\\|CXX\\|Fortran\\)$" candidate) | |||||
| (setq candidate (concat (match-string 1 candidate) "OVERRIDE_<LANG>"))) | |||||
| ((string-match "^\\(.*\\)\\(_DEBUG\\|_RELEASE\\|_RELWITHDEBINFO\\|_MINSIZEREL\\)\\(.*\\)$" candidate) | |||||
| (setq candidate (concat (match-string 1 candidate) | |||||
| "_<CONFIG>" | |||||
| (match-string 3 candidate))))) | |||||
| candidate) | |||||
| (defun company-cmake--meta (candidate) | |||||
| (let ((cmd-opts (gethash candidate company-cmake--meta-command-cache)) | |||||
| result) | |||||
| (setq candidate (company-cmake--unexpand-candidate candidate)) | |||||
| ;; Don't cache the documentation of every candidate (command) | |||||
| ;; Cache in this case will cost too much memory. | |||||
| (with-temp-buffer | |||||
| (call-process company-cmake-executable nil t nil cmd-opts candidate) | |||||
| ;; Go to the third line, trim it and return the result. | |||||
| ;; Tested with cmake 2.8.9. | |||||
| (goto-char (point-min)) | |||||
| (forward-line 2) | |||||
| (setq result (buffer-substring-no-properties (line-beginning-position) | |||||
| (line-end-position))) | |||||
| (setq result (replace-regexp-in-string "^[ \t\n\r]+" "" result)) | |||||
| result))) | |||||
| (defun company-cmake--doc-buffer (candidate) | |||||
| (let ((cmd-opts (gethash candidate company-cmake--meta-command-cache))) | |||||
| (setq candidate (company-cmake--unexpand-candidate candidate)) | |||||
| (with-temp-buffer | |||||
| (call-process company-cmake-executable nil t nil cmd-opts candidate) | |||||
| ;; Go to the third line, trim it and return the doc buffer. | |||||
| ;; Tested with cmake 2.8.9. | |||||
| (goto-char (point-min)) | |||||
| (forward-line 2) | |||||
| (company-doc-buffer | |||||
| (buffer-substring-no-properties (line-beginning-position) | |||||
| (point-max)))))) | |||||
| (defun company-cmake (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for CMake. | |||||
| CMake is a cross-platform, open-source make system." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-cmake)) | |||||
| (init (when (memq major-mode company-cmake-modes) | |||||
| (unless company-cmake-executable | |||||
| (error "Company found no cmake executable")))) | |||||
| (prefix (and (memq major-mode company-cmake-modes) | |||||
| (not (company-in-string-or-comment)) | |||||
| (company-grab-symbol))) | |||||
| (candidates (company-cmake--candidates arg)) | |||||
| (meta (company-cmake--meta arg)) | |||||
| (doc-buffer (company-cmake--doc-buffer arg)) | |||||
| )) | |||||
| (provide 'company-cmake) | |||||
| ;;; company-cmake.el ends here | |||||
| @ -0,0 +1,170 @@ | |||||
| ;;; company-dabbrev.el --- dabbrev-like company-mode completion back-end -*- lexical-binding: t -*- | |||||
| ;; Copyright (C) 2009, 2011, 2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-dabbrev nil | |||||
| "dabbrev-like completion back-end." | |||||
| :group 'company) | |||||
| (defcustom company-dabbrev-other-buffers 'all | |||||
| "Determines whether `company-dabbrev' should search other buffers. | |||||
| If `all', search all other buffers, except the ignored ones. If t, search | |||||
| buffers with the same major mode. See also `company-dabbrev-time-limit'." | |||||
| :type '(choice (const :tag "Off" nil) | |||||
| (const :tag "Same major mode" t) | |||||
| (const :tag "All" all))) | |||||
| (defcustom company-dabbrev-ignore-buffers "\\`[ *]" | |||||
| "Regexp matching the names of buffers to ignore." | |||||
| :type 'regexp) | |||||
| (defcustom company-dabbrev-time-limit .1 | |||||
| "Determines how many seconds `company-dabbrev' should look for matches." | |||||
| :type '(choice (const :tag "Off" nil) | |||||
| (number :tag "Seconds"))) | |||||
| (defcustom company-dabbrev-char-regexp "\\sw" | |||||
| "A regular expression matching the characters `company-dabbrev' looks for." | |||||
| :type 'regexp) | |||||
| (defcustom company-dabbrev-ignore-case 'keep-prefix | |||||
| "Non-nil to ignore case when collecting completion candidates. | |||||
| When it's `keep-prefix', the text before point will remain unchanged after | |||||
| candidate is inserted, even some of its characters have different case.") | |||||
| (defcustom company-dabbrev-downcase 'case-replace | |||||
| "Whether to downcase the returned candidates. | |||||
| The value of nil means keep them as-is. | |||||
| `case-replace' means use the value of `case-replace'. | |||||
| Any other value means downcase. | |||||
| If you set this value to nil, you may also want to set | |||||
| `company-dabbrev-ignore-case' to any value other than `keep-prefix'.") | |||||
| (defcustom company-dabbrev-minimum-length 4 | |||||
| "The minimum length for the completion candidate to be included. | |||||
| This variable affects both `company-dabbrev' and `company-dabbrev-code'." | |||||
| :type 'integer | |||||
| :package-version '(company . "0.8.3")) | |||||
| (defcustom company-dabbrev-ignore-invisible nil | |||||
| "Non-nil to skip invisible text." | |||||
| :type 'boolean | |||||
| :package-version '(company . "0.9.0")) | |||||
| (defmacro company-dabrev--time-limit-while (test start limit &rest body) | |||||
| (declare (indent 3) (debug t)) | |||||
| `(let ((company-time-limit-while-counter 0)) | |||||
| (catch 'done | |||||
| (while ,test | |||||
| ,@body | |||||
| (and ,limit | |||||
| (eq (cl-incf company-time-limit-while-counter) 25) | |||||
| (setq company-time-limit-while-counter 0) | |||||
| (> (float-time (time-since ,start)) ,limit) | |||||
| (throw 'done 'company-time-out)))))) | |||||
| (defsubst company-dabbrev--make-regexp (prefix) | |||||
| (concat "\\<" (if (equal prefix "") | |||||
| company-dabbrev-char-regexp | |||||
| (regexp-quote prefix)) | |||||
| "\\(" company-dabbrev-char-regexp "\\)*\\>")) | |||||
| (defun company-dabbrev--search-buffer (regexp pos symbols start limit | |||||
| ignore-comments) | |||||
| (save-excursion | |||||
| (cl-flet ((maybe-collect-match | |||||
| () | |||||
| (let ((match (match-string-no-properties 0))) | |||||
| (when (and (>= (length match) company-dabbrev-minimum-length) | |||||
| (not (and company-dabbrev-ignore-invisible | |||||
| (invisible-p (match-beginning 0))))) | |||||
| (push match symbols))))) | |||||
| (goto-char (if pos (1- pos) (point-min))) | |||||
| ;; search before pos | |||||
| (company-dabrev--time-limit-while (re-search-backward regexp nil t) | |||||
| start limit | |||||
| (if (and ignore-comments (save-match-data (company-in-string-or-comment))) | |||||
| (goto-char (nth 8 (syntax-ppss))) | |||||
| (maybe-collect-match))) | |||||
| (goto-char (or pos (point-min))) | |||||
| ;; search after pos | |||||
| (company-dabrev--time-limit-while (re-search-forward regexp nil t) | |||||
| start limit | |||||
| (if (and ignore-comments (save-match-data (company-in-string-or-comment))) | |||||
| (re-search-forward "\\s>\\|\\s!\\|\\s\"" nil t) | |||||
| (maybe-collect-match))) | |||||
| symbols))) | |||||
| (defun company-dabbrev--search (regexp &optional limit other-buffer-modes | |||||
| ignore-comments) | |||||
| (let* ((start (current-time)) | |||||
| (symbols (company-dabbrev--search-buffer regexp (point) nil start limit | |||||
| ignore-comments))) | |||||
| (when other-buffer-modes | |||||
| (cl-dolist (buffer (delq (current-buffer) (buffer-list))) | |||||
| (with-current-buffer buffer | |||||
| (when (if (eq other-buffer-modes 'all) | |||||
| (not (string-match-p company-dabbrev-ignore-buffers | |||||
| (buffer-name))) | |||||
| (apply #'derived-mode-p other-buffer-modes)) | |||||
| (setq symbols | |||||
| (company-dabbrev--search-buffer regexp nil symbols start | |||||
| limit ignore-comments)))) | |||||
| (and limit | |||||
| (> (float-time (time-since start)) limit) | |||||
| (cl-return)))) | |||||
| symbols)) | |||||
| ;;;###autoload | |||||
| (defun company-dabbrev (command &optional arg &rest ignored) | |||||
| "dabbrev-like `company-mode' completion back-end." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-dabbrev)) | |||||
| (prefix (company-grab-word)) | |||||
| (candidates | |||||
| (let* ((case-fold-search company-dabbrev-ignore-case) | |||||
| (words (company-dabbrev--search (company-dabbrev--make-regexp arg) | |||||
| company-dabbrev-time-limit | |||||
| (pcase company-dabbrev-other-buffers | |||||
| (`t (list major-mode)) | |||||
| (`all `all)))) | |||||
| (downcase-p (if (eq company-dabbrev-downcase 'case-replace) | |||||
| case-replace | |||||
| company-dabbrev-downcase))) | |||||
| (if downcase-p | |||||
| (mapcar 'downcase words) | |||||
| words))) | |||||
| (ignore-case company-dabbrev-ignore-case) | |||||
| (duplicates t))) | |||||
| (provide 'company-dabbrev) | |||||
| ;;; company-dabbrev.el ends here | |||||
| @ -0,0 +1,94 @@ | |||||
| ;;; company-etags.el --- company-mode completion back-end for etags | |||||
| ;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (require 'etags) | |||||
| (defgroup company-etags nil | |||||
| "Completion back-end for etags." | |||||
| :group 'company) | |||||
| (defcustom company-etags-use-main-table-list t | |||||
| "Always search `tags-table-list' if set. | |||||
| If this is disabled, `company-etags' will try to find the one table for each | |||||
| buffer automatically." | |||||
| :type '(choice (const :tag "off" nil) | |||||
| (const :tag "on" t))) | |||||
| (defcustom company-etags-ignore-case nil | |||||
| "Non-nil to ignore case in completion candidates." | |||||
| :type 'boolean | |||||
| :package-version '(company . "0.7.3")) | |||||
| (defvar company-etags-modes '(prog-mode c-mode objc-mode c++-mode java-mode | |||||
| jde-mode pascal-mode perl-mode python-mode)) | |||||
| (defvar-local company-etags-buffer-table 'unknown) | |||||
| (defun company-etags-find-table () | |||||
| (let ((file (locate-dominating-file (or buffer-file-name | |||||
| default-directory) | |||||
| "TAGS"))) | |||||
| (when (and file (file-regular-p file)) | |||||
| (list (expand-file-name file))))) | |||||
| (defun company-etags-buffer-table () | |||||
| (or (and company-etags-use-main-table-list tags-table-list) | |||||
| (if (eq company-etags-buffer-table 'unknown) | |||||
| (setq company-etags-buffer-table (company-etags-find-table)) | |||||
| company-etags-buffer-table))) | |||||
| (defun company-etags--candidates (prefix) | |||||
| (let ((tags-table-list (company-etags-buffer-table)) | |||||
| (completion-ignore-case company-etags-ignore-case)) | |||||
| (and (or tags-file-name tags-table-list) | |||||
| (fboundp 'tags-completion-table) | |||||
| (save-excursion | |||||
| (visit-tags-table-buffer) | |||||
| (all-completions prefix (tags-completion-table)))))) | |||||
| ;;;###autoload | |||||
| (defun company-etags (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for etags." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-etags)) | |||||
| (prefix (and (apply 'derived-mode-p company-etags-modes) | |||||
| (not (company-in-string-or-comment)) | |||||
| (company-etags-buffer-table) | |||||
| (or (company-grab-symbol) 'stop))) | |||||
| (candidates (company-etags--candidates arg)) | |||||
| (location (let ((tags-table-list (company-etags-buffer-table))) | |||||
| (when (fboundp 'find-tag-noselect) | |||||
| (save-excursion | |||||
| (let ((buffer (find-tag-noselect arg))) | |||||
| (cons buffer (with-current-buffer buffer (point)))))))) | |||||
| (ignore-case company-etags-ignore-case))) | |||||
| (provide 'company-etags) | |||||
| ;;; company-etags.el ends here | |||||
| @ -0,0 +1,111 @@ | |||||
| ;;; company-files.el --- company-mode completion back-end for file paths | |||||
| ;; Copyright (C) 2009-2011, 2014-2015 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defun company-files--directory-files (dir prefix) | |||||
| (ignore-errors | |||||
| (if (equal prefix "") | |||||
| (directory-files dir nil "\\`[^.]\\|\\`.[^.]") | |||||
| (file-name-all-completions prefix dir)))) | |||||
| (defvar company-files--regexps | |||||
| (let* ((root (if (eq system-type 'windows-nt) | |||||
| "[a-zA-Z]:/" | |||||
| "/")) | |||||
| (begin (concat "\\(?:\\.\\{1,2\\}/\\|~/\\|" root "\\)"))) | |||||
| (list (concat "\"\\(" begin "[^\"\n]*\\)") | |||||
| (concat "\'\\(" begin "[^\'\n]*\\)") | |||||
| (concat "\\(?:[ \t]\\|^\\)\\(" begin "[^ \t\n]*\\)")))) | |||||
| (defun company-files--grab-existing-name () | |||||
| ;; Grab the file name. | |||||
| ;; When surrounded with quotes, it can include spaces. | |||||
| (let (file dir) | |||||
| (and (cl-dolist (regexp company-files--regexps) | |||||
| (when (setq file (company-grab-line regexp 1)) | |||||
| (cl-return file))) | |||||
| (company-files--connected-p file) | |||||
| (setq dir (file-name-directory file)) | |||||
| (not (string-match "//" dir)) | |||||
| (file-exists-p dir) | |||||
| (file-name-all-completions (file-name-nondirectory file) dir) | |||||
| file))) | |||||
| (defun company-files--connected-p (file) | |||||
| (or (not (file-remote-p file)) | |||||
| (file-remote-p file nil t))) | |||||
| (defvar company-files--completion-cache nil) | |||||
| (defun company-files--complete (prefix) | |||||
| (let* ((dir (file-name-directory prefix)) | |||||
| (key (list (file-name-nondirectory prefix) | |||||
| (expand-file-name dir) | |||||
| (nth 5 (file-attributes dir)))) | |||||
| (file (file-name-nondirectory prefix)) | |||||
| (completion-ignore-case read-file-name-completion-ignore-case) | |||||
| candidates directories) | |||||
| (unless (company-file--keys-match-p key (car company-files--completion-cache)) | |||||
| (dolist (file (company-files--directory-files dir file)) | |||||
| (setq file (concat dir file)) | |||||
| (when (company-files--connected-p file) | |||||
| (push file candidates) | |||||
| (when (file-directory-p file) | |||||
| (push file directories)))) | |||||
| (dolist (directory (reverse directories)) | |||||
| ;; Add one level of children. | |||||
| (dolist (child (company-files--directory-files directory "")) | |||||
| (push (concat directory | |||||
| (unless (eq (aref directory (1- (length directory))) ?/) "/") | |||||
| child) candidates))) | |||||
| (setq company-files--completion-cache (cons key (nreverse candidates)))) | |||||
| (all-completions prefix | |||||
| (cdr company-files--completion-cache)))) | |||||
| (defun company-file--keys-match-p (new old) | |||||
| (and (equal (cdr old) (cdr new)) | |||||
| (string-prefix-p (car old) (car new)))) | |||||
| ;;;###autoload | |||||
| (defun company-files (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end existing file names. | |||||
| Completions works for proper absolute and relative files paths. | |||||
| File paths with spaces are only supported inside strings." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-files)) | |||||
| (prefix (company-files--grab-existing-name)) | |||||
| (candidates (company-files--complete arg)) | |||||
| (location (cons (dired-noselect | |||||
| (file-name-directory (directory-file-name arg))) 1)) | |||||
| (sorted t) | |||||
| (no-cache t))) | |||||
| (provide 'company-files) | |||||
| ;;; company-files.el ends here | |||||
| @ -0,0 +1,116 @@ | |||||
| ;;; company-gtags.el --- company-mode completion back-end for GNU Global | |||||
| ;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'company-template) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-gtags nil | |||||
| "Completion back-end for GNU Global." | |||||
| :group 'company) | |||||
| (defcustom company-gtags-executable | |||||
| (executable-find "global") | |||||
| "Location of GNU global executable." | |||||
| :type 'string) | |||||
| (define-obsolete-variable-alias | |||||
| 'company-gtags-gnu-global-program-name | |||||
| 'company-gtags-executable "earlier") | |||||
| (defcustom company-gtags-insert-arguments t | |||||
| "When non-nil, insert function arguments as a template after completion." | |||||
| :type 'boolean | |||||
| :package-version '(company . "0.8.1")) | |||||
| (defvar-local company-gtags--tags-available-p 'unknown) | |||||
| (defcustom company-gtags-modes '(prog-mode jde-mode) | |||||
| "Modes that use `company-gtags'. | |||||
| In all these modes (and their derivatives) `company-gtags' will perform | |||||
| completion." | |||||
| :type '(repeat (symbol :tag "Major mode")) | |||||
| :package-version '(company . "0.8.4")) | |||||
| (defun company-gtags--tags-available-p () | |||||
| (if (eq company-gtags--tags-available-p 'unknown) | |||||
| (setq company-gtags--tags-available-p | |||||
| (locate-dominating-file buffer-file-name "GTAGS")) | |||||
| company-gtags--tags-available-p)) | |||||
| (defun company-gtags--fetch-tags (prefix) | |||||
| (with-temp-buffer | |||||
| (let (tags) | |||||
| (when (= 0 (call-process company-gtags-executable nil | |||||
| (list (current-buffer) nil) nil "-xGq" (concat "^" prefix))) | |||||
| (goto-char (point-min)) | |||||
| (cl-loop while | |||||
| (re-search-forward (concat | |||||
| "^" | |||||
| "\\([^ ]*\\)" ;; completion | |||||
| "[ \t]+\\([[:digit:]]+\\)" ;; linum | |||||
| "[ \t]+\\([^ \t]+\\)" ;; file | |||||
| "[ \t]+\\(.*\\)" ;; definition | |||||
| "$" | |||||
| ) nil t) | |||||
| collect | |||||
| (propertize (match-string 1) | |||||
| 'meta (match-string 4) | |||||
| 'location (cons (expand-file-name (match-string 3)) | |||||
| (string-to-number (match-string 2))) | |||||
| )))))) | |||||
| (defun company-gtags--annotation (arg) | |||||
| (let ((meta (get-text-property 0 'meta arg))) | |||||
| (when (string-match (concat arg "\\((.*)\\).*") meta) | |||||
| (match-string 1 meta)))) | |||||
| ;;;###autoload | |||||
| (defun company-gtags (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for GNU Global." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-gtags)) | |||||
| (prefix (and company-gtags-executable | |||||
| buffer-file-name | |||||
| (apply #'derived-mode-p company-gtags-modes) | |||||
| (not (company-in-string-or-comment)) | |||||
| (company-gtags--tags-available-p) | |||||
| (or (company-grab-symbol) 'stop))) | |||||
| (candidates (company-gtags--fetch-tags arg)) | |||||
| (sorted t) | |||||
| (duplicates t) | |||||
| (annotation (company-gtags--annotation arg)) | |||||
| (meta (get-text-property 0 'meta arg)) | |||||
| (location (get-text-property 0 'location arg)) | |||||
| (post-completion (let ((anno (company-gtags--annotation arg))) | |||||
| (when (and company-gtags-insert-arguments anno) | |||||
| (insert anno) | |||||
| (company-template-c-like-templatify anno)))))) | |||||
| (provide 'company-gtags) | |||||
| ;;; company-gtags.el ends here | |||||
| @ -0,0 +1,76 @@ | |||||
| ;;; company-ispell.el --- company-mode completion back-end using Ispell | |||||
| ;; Copyright (C) 2009-2011, 2013-2015 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (require 'ispell) | |||||
| (defgroup company-ispell nil | |||||
| "Completion back-end using Ispell." | |||||
| :group 'company) | |||||
| (defcustom company-ispell-dictionary nil | |||||
| "Dictionary to use for `company-ispell'. | |||||
| If nil, use `ispell-complete-word-dict'." | |||||
| :type '(choice (const :tag "default (nil)" nil) | |||||
| (file :tag "dictionary" t))) | |||||
| (defvar company-ispell-available 'unknown) | |||||
| (defun company-ispell-available () | |||||
| (when (eq company-ispell-available 'unknown) | |||||
| (condition-case err | |||||
| (progn | |||||
| (lookup-words "WHATEVER") | |||||
| (setq company-ispell-available t)) | |||||
| (error | |||||
| (message "Company: ispell-look-command not found") | |||||
| (setq company-ispell-available nil)))) | |||||
| company-ispell-available) | |||||
| ;;;###autoload | |||||
| (defun company-ispell (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end using Ispell." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-ispell)) | |||||
| (prefix (when (company-ispell-available) | |||||
| (company-grab-word))) | |||||
| (candidates | |||||
| (let ((words (lookup-words arg (or company-ispell-dictionary | |||||
| ispell-complete-word-dict))) | |||||
| (completion-ignore-case t)) | |||||
| (if (string= arg "") | |||||
| ;; Small optimization. | |||||
| words | |||||
| ;; Work around issue #284. | |||||
| (all-completions arg words)))) | |||||
| (sorted t) | |||||
| (ignore-case 'keep-prefix))) | |||||
| (provide 'company-ispell) | |||||
| ;;; company-ispell.el ends here | |||||
| @ -0,0 +1,8 @@ | |||||
| (define-package "company" "20150503.1854" "Modular text completion framework" | |||||
| '((emacs "24.1") | |||||
| (cl-lib "0.5")) | |||||
| :url "http://company-mode.github.io/" :keywords | |||||
| '("abbrev" "convenience" "matching")) | |||||
| ;; Local Variables: | |||||
| ;; no-byte-compile: t | |||||
| ;; End: | |||||
| @ -0,0 +1,156 @@ | |||||
| ;;; company-semantic.el --- company-mode completion back-end using Semantic | |||||
| ;; Copyright (C) 2009-2011, 2013 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defvar semantic-idle-summary-function) | |||||
| (declare-function semantic-documentation-for-tag "semantic/doc" ) | |||||
| (declare-function semantic-analyze-current-context "semantic/analyze") | |||||
| (declare-function semantic-analyze-possible-completions "semantic/complete") | |||||
| (declare-function semantic-analyze-find-tags-by-prefix "semantic/analyze/fcn") | |||||
| (declare-function semantic-tag-class "semantic/tag") | |||||
| (declare-function semantic-tag-name "semantic/tag") | |||||
| (declare-function semantic-tag-start "semantic/tag") | |||||
| (declare-function semantic-tag-buffer "semantic/tag") | |||||
| (declare-function semantic-active-p "semantic") | |||||
| (defgroup company-semantic nil | |||||
| "Completion back-end using Semantic." | |||||
| :group 'company) | |||||
| (defcustom company-semantic-metadata-function 'company-semantic-summary-and-doc | |||||
| "The function turning a semantic tag into doc information." | |||||
| :type 'function) | |||||
| (defvar company-semantic-modes '(c-mode c++-mode jde-mode java-mode)) | |||||
| (defvar-local company-semantic--current-tags nil | |||||
| "Tags for the current context.") | |||||
| (defun company-semantic-documentation-for-tag (tag) | |||||
| (when (semantic-tag-buffer tag) | |||||
| ;; When TAG's buffer is unknown, the function below raises an error. | |||||
| (semantic-documentation-for-tag tag))) | |||||
| (defun company-semantic-doc-or-summary (tag) | |||||
| (or (company-semantic-documentation-for-tag tag) | |||||
| (and (require 'semantic-idle nil t) | |||||
| (require 'semantic/idle nil t) | |||||
| (funcall semantic-idle-summary-function tag nil t)))) | |||||
| (defun company-semantic-summary-and-doc (tag) | |||||
| (let ((doc (company-semantic-documentation-for-tag tag)) | |||||
| (summary (funcall semantic-idle-summary-function tag nil t))) | |||||
| (and (stringp doc) | |||||
| (string-match "\n*\\(.*\\)$" doc) | |||||
| (setq doc (match-string 1 doc))) | |||||
| (concat summary | |||||
| (when doc | |||||
| (if (< (+ (length doc) (length summary) 4) (window-width)) | |||||
| " -- " | |||||
| "\n")) | |||||
| doc))) | |||||
| (defun company-semantic-doc-buffer (tag) | |||||
| (let ((doc (company-semantic-documentation-for-tag tag))) | |||||
| (when doc | |||||
| (company-doc-buffer | |||||
| (concat (funcall semantic-idle-summary-function tag nil t) | |||||
| "\n" | |||||
| doc))))) | |||||
| (defsubst company-semantic-completions (prefix) | |||||
| (ignore-errors | |||||
| (let ((completion-ignore-case nil) | |||||
| (context (semantic-analyze-current-context))) | |||||
| (setq company-semantic--current-tags | |||||
| (semantic-analyze-possible-completions context)) | |||||
| (all-completions prefix company-semantic--current-tags)))) | |||||
| (defun company-semantic-completions-raw (prefix) | |||||
| (setq company-semantic--current-tags nil) | |||||
| (dolist (tag (semantic-analyze-find-tags-by-prefix prefix)) | |||||
| (unless (eq (semantic-tag-class tag) 'include) | |||||
| (push tag company-semantic--current-tags))) | |||||
| (delete "" (mapcar 'semantic-tag-name company-semantic--current-tags))) | |||||
| (defun company-semantic-annotation (argument tags) | |||||
| (let* ((tag (assoc argument tags)) | |||||
| (kind (when tag (elt tag 1)))) | |||||
| (cl-case kind | |||||
| (function (let* ((prototype (semantic-format-tag-prototype tag nil nil)) | |||||
| (par-pos (string-match "(" prototype))) | |||||
| (when par-pos (substring prototype par-pos))))))) | |||||
| (defun company-semantic--pre-prefix-length (prefix-length) | |||||
| "Sum up the length of all chained symbols before POS. | |||||
| Symbols are chained by \".\" or \"->\"." | |||||
| (save-excursion | |||||
| (let ((pos (point))) | |||||
| (goto-char (- (point) prefix-length)) | |||||
| (while (looking-back "->\\|\\.") | |||||
| (goto-char (match-beginning 0)) | |||||
| (skip-syntax-backward "w_")) | |||||
| (- pos (point))))) | |||||
| (defun company-semantic--grab () | |||||
| "Grab the semantic prefix, but return everything before -> or . as length." | |||||
| (let ((symbol (company-grab-symbol))) | |||||
| (when symbol | |||||
| (cons symbol (company-semantic--pre-prefix-length (length symbol)))))) | |||||
| ;;;###autoload | |||||
| (defun company-semantic (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end using CEDET Semantic." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-semantic)) | |||||
| (prefix (and (featurep 'semantic) | |||||
| (semantic-active-p) | |||||
| (memq major-mode company-semantic-modes) | |||||
| (not (company-in-string-or-comment)) | |||||
| (or (company-semantic--grab) 'stop))) | |||||
| (candidates (if (and (equal arg "") | |||||
| (not (looking-back "->\\|\\."))) | |||||
| (company-semantic-completions-raw arg) | |||||
| (company-semantic-completions arg))) | |||||
| (meta (funcall company-semantic-metadata-function | |||||
| (assoc arg company-semantic--current-tags))) | |||||
| (annotation (company-semantic-annotation arg | |||||
| company-semantic--current-tags)) | |||||
| (doc-buffer (company-semantic-doc-buffer | |||||
| (assoc arg company-semantic--current-tags))) | |||||
| ;; Because "" is an empty context and doesn't return local variables. | |||||
| (no-cache (equal arg "")) | |||||
| (location (let ((tag (assoc arg company-semantic--current-tags))) | |||||
| (when (buffer-live-p (semantic-tag-buffer tag)) | |||||
| (cons (semantic-tag-buffer tag) | |||||
| (semantic-tag-start tag))))))) | |||||
| (provide 'company-semantic) | |||||
| ;;; company-semantic.el ends here | |||||
| @ -0,0 +1,214 @@ | |||||
| ;;; company-template.el | |||||
| ;; Copyright (C) 2009, 2010, 2014-2015 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Code: | |||||
| (require 'cl-lib) | |||||
| (defface company-template-field | |||||
| '((((background dark)) (:background "yellow" :foreground "black")) | |||||
| (((background light)) (:background "orange" :foreground "black"))) | |||||
| "Face used for editable text in template fields." | |||||
| :group 'company) | |||||
| (defvar company-template-nav-map | |||||
| (let ((keymap (make-sparse-keymap))) | |||||
| (define-key keymap [tab] 'company-template-forward-field) | |||||
| (define-key keymap (kbd "TAB") 'company-template-forward-field) | |||||
| keymap)) | |||||
| (defvar-local company-template--buffer-templates nil) | |||||
| ;; interactive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-template-templates-at (pos) | |||||
| (let (os) | |||||
| (dolist (o (overlays-at pos)) | |||||
| ;; FIXME: Always return the whole list of templates? | |||||
| ;; We remove templates not at point after every command. | |||||
| (when (memq o company-template--buffer-templates) | |||||
| (push o os))) | |||||
| os)) | |||||
| (defun company-template-move-to-first (templ) | |||||
| (interactive) | |||||
| (goto-char (overlay-start templ)) | |||||
| (company-template-forward-field)) | |||||
| (defun company-template-forward-field () | |||||
| (interactive) | |||||
| (let* ((start (point)) | |||||
| (templates (company-template-templates-at (point))) | |||||
| (minimum (apply 'max (mapcar 'overlay-end templates))) | |||||
| (fields (cl-loop for templ in templates | |||||
| append (overlay-get templ 'company-template-fields)))) | |||||
| (dolist (pos (mapcar 'overlay-start fields)) | |||||
| (and pos | |||||
| (> pos (point)) | |||||
| (< pos minimum) | |||||
| (setq minimum pos))) | |||||
| (push-mark) | |||||
| (goto-char minimum) | |||||
| (company-template-remove-field (company-template-field-at start)))) | |||||
| (defun company-template-field-at (&optional point) | |||||
| (cl-loop for ovl in (overlays-at (or point (point))) | |||||
| when (overlay-get ovl 'company-template-parent) | |||||
| return ovl)) | |||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-template-declare-template (beg end) | |||||
| (let ((ov (make-overlay beg end))) | |||||
| ;; (overlay-put ov 'face 'highlight) | |||||
| (overlay-put ov 'keymap company-template-nav-map) | |||||
| (overlay-put ov 'priority 101) | |||||
| (overlay-put ov 'evaporate t) | |||||
| (push ov company-template--buffer-templates) | |||||
| (add-hook 'post-command-hook 'company-template-post-command nil t) | |||||
| ov)) | |||||
| (defun company-template-remove-template (templ) | |||||
| (mapc 'company-template-remove-field | |||||
| (overlay-get templ 'company-template-fields)) | |||||
| (setq company-template--buffer-templates | |||||
| (delq templ company-template--buffer-templates)) | |||||
| (delete-overlay templ)) | |||||
| (defun company-template-add-field (templ beg end &optional display) | |||||
| "Add new field to template TEMPL spanning from BEG to END. | |||||
| When DISPLAY is non-nil, set the respective property on the overlay. | |||||
| Leave point at the end of the field." | |||||
| (cl-assert templ) | |||||
| (when (> end (overlay-end templ)) | |||||
| (move-overlay templ (overlay-start templ) end)) | |||||
| (let ((ov (make-overlay beg end)) | |||||
| (siblings (overlay-get templ 'company-template-fields))) | |||||
| ;; (overlay-put ov 'evaporate t) | |||||
| (overlay-put ov 'intangible t) | |||||
| (overlay-put ov 'face 'company-template-field) | |||||
| (when display | |||||
| (overlay-put ov 'display display)) | |||||
| (overlay-put ov 'company-template-parent templ) | |||||
| (overlay-put ov 'insert-in-front-hooks '(company-template-insert-hook)) | |||||
| (push ov siblings) | |||||
| (overlay-put templ 'company-template-fields siblings))) | |||||
| (defun company-template-remove-field (ovl &optional clear) | |||||
| (when (overlayp ovl) | |||||
| (when (overlay-buffer ovl) | |||||
| (when clear | |||||
| (delete-region (overlay-start ovl) (overlay-end ovl))) | |||||
| (delete-overlay ovl)) | |||||
| (let* ((templ (overlay-get ovl 'company-template-parent)) | |||||
| (siblings (overlay-get templ 'company-template-fields))) | |||||
| (setq siblings (delq ovl siblings)) | |||||
| (overlay-put templ 'company-template-fields siblings)))) | |||||
| (defun company-template-clean-up (&optional pos) | |||||
| "Clean up all templates that don't contain POS." | |||||
| (let ((local-ovs (overlays-at (or pos (point))))) | |||||
| (dolist (templ company-template--buffer-templates) | |||||
| (unless (memq templ local-ovs) | |||||
| (company-template-remove-template templ))))) | |||||
| ;; hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-template-insert-hook (ovl after-p &rest _ignore) | |||||
| "Called when a snippet input prompt is modified." | |||||
| (unless after-p | |||||
| (company-template-remove-field ovl t))) | |||||
| (defun company-template-post-command () | |||||
| (company-template-clean-up) | |||||
| (unless company-template--buffer-templates | |||||
| (remove-hook 'post-command-hook 'company-template-post-command t))) | |||||
| ;; common ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-template-c-like-templatify (call) | |||||
| (let* ((end (point-marker)) | |||||
| (beg (- (point) (length call))) | |||||
| (templ (company-template-declare-template beg end)) | |||||
| paren-open paren-close) | |||||
| (with-syntax-table (make-syntax-table (syntax-table)) | |||||
| (modify-syntax-entry ?< "(") | |||||
| (modify-syntax-entry ?> ")") | |||||
| (when (search-backward ")" beg t) | |||||
| (setq paren-close (point-marker)) | |||||
| (forward-char 1) | |||||
| (delete-region (point) end) | |||||
| (backward-sexp) | |||||
| (forward-char 1) | |||||
| (setq paren-open (point-marker))) | |||||
| (when (search-backward ">" beg t) | |||||
| (let ((angle-close (point-marker))) | |||||
| (forward-char 1) | |||||
| (backward-sexp) | |||||
| (forward-char) | |||||
| (company-template--c-like-args templ angle-close))) | |||||
| (when (looking-back "\\((\\*)\\)(" (line-beginning-position)) | |||||
| (delete-region (match-beginning 1) (match-end 1))) | |||||
| (when paren-open | |||||
| (goto-char paren-open) | |||||
| (company-template--c-like-args templ paren-close))) | |||||
| (if (overlay-get templ 'company-template-fields) | |||||
| (company-template-move-to-first templ) | |||||
| (company-template-remove-template templ) | |||||
| (goto-char end)))) | |||||
| (defun company-template--c-like-args (templ end) | |||||
| (let ((last-pos (point))) | |||||
| (while (re-search-forward "\\([^,]+\\),?" end 'move) | |||||
| (when (zerop (car (parse-partial-sexp last-pos (point)))) | |||||
| (company-template-add-field templ last-pos (match-end 1)) | |||||
| (skip-chars-forward " ") | |||||
| (setq last-pos (point)))))) | |||||
| ;; objc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-clang-objc-templatify (selector) | |||||
| (let* ((end (point-marker)) | |||||
| (beg (- (point) (length selector) 1)) | |||||
| (templ (company-template-declare-template beg end)) | |||||
| (cnt 0)) | |||||
| (save-excursion | |||||
| (goto-char beg) | |||||
| (catch 'stop | |||||
| (while (search-forward ":" end t) | |||||
| (if (looking-at "\\(([^)]*)\\) ?") | |||||
| (company-template-add-field templ (point) (match-end 1)) | |||||
| ;; Not sure which conditions this case manifests under, but | |||||
| ;; apparently it did before, when I wrote the first test for this | |||||
| ;; function. FIXME: Revisit it. | |||||
| (company-template-add-field templ (point) | |||||
| (progn | |||||
| (insert (format "arg%d" cnt)) | |||||
| (point))) | |||||
| (when (< (point) end) | |||||
| (insert " ")) | |||||
| (cl-incf cnt)) | |||||
| (when (>= (point) end) | |||||
| (throw 'stop t))))) | |||||
| (company-template-move-to-first templ))) | |||||
| (provide 'company-template) | |||||
| ;;; company-template.el ends here | |||||
| @ -0,0 +1,123 @@ | |||||
| ;;; company-xcode.el --- company-mode completion back-end for Xcode projects | |||||
| ;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. | |||||
| ;; Author: Nikolaj Schumacher | |||||
| ;; This file is part of GNU Emacs. | |||||
| ;; GNU Emacs is free software: you can redistribute it and/or modify | |||||
| ;; it under the terms of the GNU General Public License as published by | |||||
| ;; the Free Software Foundation, either version 3 of the License, or | |||||
| ;; (at your option) any later version. | |||||
| ;; GNU Emacs is distributed in the hope that it will be useful, | |||||
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| ;; GNU General Public License for more details. | |||||
| ;; You should have received a copy of the GNU General Public License | |||||
| ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||||
| ;;; Commentary: | |||||
| ;; | |||||
| ;;; Code: | |||||
| (require 'company) | |||||
| (require 'cl-lib) | |||||
| (defgroup company-xcode nil | |||||
| "Completion back-end for Xcode projects." | |||||
| :group 'company) | |||||
| (defcustom company-xcode-xcodeindex-executable (executable-find "xcodeindex") | |||||
| "Location of xcodeindex executable." | |||||
| :type 'file) | |||||
| (defvar company-xcode-tags nil) | |||||
| (defun company-xcode-reset () | |||||
| "Reset the cached tags." | |||||
| (interactive) | |||||
| (setq company-xcode-tags nil)) | |||||
| (defcustom company-xcode-types | |||||
| '("Class" "Constant" "Enum" "Macro" "Modeled Class" "Structure" | |||||
| "Type" "Union" "Function") | |||||
| "The types of symbols offered by `company-xcode'. | |||||
| No context-enabled completion is available. Types like methods will be | |||||
| offered regardless of whether the class supports them. The defaults should be | |||||
| valid in most contexts." | |||||
| :set (lambda (variable value) | |||||
| (set variable value) | |||||
| (company-xcode-reset)) | |||||
| :type '(set (const "Category") (const "Class") (const "Class Method") | |||||
| (const "Class Variable") (const "Constant") (const "Enum") | |||||
| (const "Field") (const "Instance Method") | |||||
| (const "Instance Variable") (const "Macro") | |||||
| (const "Modeled Class") (const "Modeled Method") | |||||
| (const "Modeled Property") (const "Property") (const "Protocol") | |||||
| (const "Structure") (const "Type") (const "Union") | |||||
| (const "Variable") (const "Function"))) | |||||
| (defvar-local company-xcode-project 'unknown) | |||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||||
| (defun company-xcode-fetch (project-bundle) | |||||
| (setq project-bundle (directory-file-name project-bundle)) | |||||
| (message "Retrieving dump from %s..." project-bundle) | |||||
| (with-temp-buffer | |||||
| (let ((default-directory (file-name-directory project-bundle))) | |||||
| (call-process company-xcode-xcodeindex-executable nil (current-buffer) | |||||
| nil "dump" "-project" | |||||
| (file-name-nondirectory project-bundle) "-quiet") | |||||
| (goto-char (point-min)) | |||||
| (let ((regexp (concat "^\\([^\t\n]*\\)\t[^\t\n]*\t" | |||||
| (regexp-opt company-xcode-types) | |||||
| "\t[^\t\n]*\t[^\t\n]*")) | |||||
| candidates) | |||||
| (while (re-search-forward regexp nil t) | |||||
| (cl-pushnew (match-string 1) candidates :test #'equal)) | |||||
| (message "Retrieving dump from %s...done" project-bundle) | |||||
| candidates)))) | |||||
| (defun company-xcode-find-project () | |||||
| (let ((dir (if buffer-file-name | |||||
| (file-name-directory buffer-file-name) | |||||
| (expand-file-name default-directory))) | |||||
| (prev-dir nil) | |||||
| file) | |||||
| (while (not (or file (equal dir prev-dir))) | |||||
| (setq file (car (directory-files dir t ".xcodeproj\\'" t)) | |||||
| prev-dir dir | |||||
| dir (file-name-directory (directory-file-name dir)))) | |||||
| file)) | |||||
| (defun company-xcode-tags () | |||||
| (when (eq company-xcode-project 'unknown) | |||||
| (setq company-xcode-project (company-xcode-find-project))) | |||||
| (when company-xcode-project | |||||
| (cdr (or (assoc company-xcode-project company-xcode-tags) | |||||
| (car (push (cons company-xcode-project | |||||
| (company-xcode-fetch company-xcode-project)) | |||||
| company-xcode-tags)))))) | |||||
| ;;;###autoload | |||||
| (defun company-xcode (command &optional arg &rest ignored) | |||||
| "`company-mode' completion back-end for Xcode projects." | |||||
| (interactive (list 'interactive)) | |||||
| (cl-case command | |||||
| (interactive (company-begin-backend 'company-xcode)) | |||||
| (prefix (and company-xcode-xcodeindex-executable | |||||
| (company-xcode-tags) | |||||
| (not (company-in-string-or-comment)) | |||||
| (or (company-grab-symbol) 'stop))) | |||||
| (candidates (let ((completion-ignore-case nil)) | |||||
| (company-xcode-tags) | |||||
| (all-completions arg (company-xcode-tags)))))) | |||||
| (provide 'company-xcode) | |||||
| ;;; company-xcode.el ends here | |||||