[pure-lang-svn] SF.net SVN: pure-lang: [233] pure/trunk/pure-mode.el.in
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-06-14 20:58:28
|
Revision: 233 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=233&view=rev Author: agraef Date: 2008-06-14 13:58:03 -0700 (Sat, 14 Jun 2008) Log Message: ----------- Make completion work in Emacs mode. Modified Paths: -------------- pure/trunk/pure-mode.el.in Modified: pure/trunk/pure-mode.el.in =================================================================== --- pure/trunk/pure-mode.el.in 2008-06-14 20:10:24 UTC (rev 232) +++ pure/trunk/pure-mode.el.in 2008-06-14 20:58:03 UTC (rev 233) @@ -813,43 +813,36 @@ ;; completion -;; XXXFIXME: Currently this just calls the comint-dynamic-complete function, -;; as the Pure interpreter doesn't understand the completion_matches command -;; right now. - (defun pure-complete () "Perform completion on the token preceding point." (interactive) - (comint-dynamic-complete)) + (if (pure-at-command-prompt-p) + (let* ((end (point)) + (command + (save-excursion + ;; skip back one word/identifier or operator (punctuation) + (skip-syntax-backward "w_") + (and (eq (point) end) + (skip-syntax-backward ".")) + (and (looking-at pure-prompt-regexp) + (goto-char (match-end 0))) + (buffer-substring-no-properties (point) end)))) + (pure-send-list-and-digest + (list (concat "completion_matches " command "\n"))) + ;; Sort the list + (setq pure-output-list + (sort pure-output-list 'string-lessp)) + ;; Remove duplicates + (let* ((x pure-output-list) + (y (cdr x))) + (while y + (if (string-equal (car x) (car y)) + (setcdr x (setq y (cdr y))) + (setq x y + y (cdr y))))) + ;; And let comint handle the rest + (comint-dynamic-simple-complete command pure-output-list)))) -; (defun pure-complete () -; "Perform completion on the token preceding point." -; (interactive) -; (if (pure-at-command-prompt-p) -; (let* ((end (point)) -; (command -; (save-excursion -; ;; skip over anything but whitespace, quotes and parentheses -; (skip-syntax-backward "w_.\\$'<>") -; (and (looking-at pure-prompt-regexp) -; (goto-char (match-end 0))) -; (buffer-substring-no-properties (point) end)))) -; (pure-send-list-and-digest -; (list (concat "completion_matches \"" command "\"\n"))) -; ;; Sort the list -; (setq pure-output-list -; (sort pure-output-list 'string-lessp)) -; ;; Remove duplicates -; (let* ((x pure-output-list) -; (y (cdr x))) -; (while y -; (if (string-equal (car x) (car y)) -; (setcdr x (setq y (cdr y))) -; (setq x y -; y (cdr y))))) -; ;; And let comint handle the rest -; (comint-dynamic-simple-complete command pure-output-list)))) - ;; send commands to the Q interpreter and digest their results (defun pure-output-digest (proc string) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |