Fix issue #135: 'Emacs temporary files cause DCD to crash'. dcd-server now ignores files starting with '.#'

This commit is contained in:
Atila Neves 2014-08-03 16:56:36 +02:00
parent fd1ac7e07a
commit 46b3370913
2 changed files with 25 additions and 25 deletions

View File

@ -74,7 +74,7 @@ If you want to restart server, use `ac-dcd-init-server' instead."
"Start dcd-server." "Start dcd-server."
(let ((buf (get-buffer-create "*dcd-server*"))) (let ((buf (get-buffer-create "*dcd-server*")))
(with-current-buffer buf (start-process "dcd-server" (current-buffer) (with-current-buffer buf (start-process "dcd-server" (current-buffer)
ac-dcd-server-executable ac-dcd-server-executable
(mapconcat 'identity ac-dcd-flags " ") (mapconcat 'identity ac-dcd-flags " ")
"-p" "-p"
(format "%s" ac-dcd-server-port) (format "%s" ac-dcd-server-port)
@ -150,21 +150,19 @@ If you want to restart server, use `ac-dcd-init-server' instead."
;; utility functions to call process ;; utility functions to call process
(defun ac-dcd-call-process (prefix &rest args)
(defun ac-dcd-call-process (prefix args) (if (null ac-dcd-executable)
(let ((buf (get-buffer-create ac-dcd-output-buffer-name)) (error (format "Could not find dcd-client executable"))
res) (let ((buf (get-buffer-create "*dcd-output*"))
(with-current-buffer buf (erase-buffer)) res)
(setq res (apply 'call-process-region (point-min) (point-max) (with-current-buffer buf (erase-buffer))
ac-dcd-executable nil buf nil (setq res (apply 'call-process-region (point-min) (point-max)
args ac-dcd-executable nil buf nil args))
)) (with-current-buffer buf
(with-current-buffer buf (unless (eq 0 res)
(goto-char (point-min)) (ac-dcd-handle-error res args))
(when (re-search-forward ac-dcd-error-message-regexp nil t) ;; Still try to get any useful input.
(ac-dcd-handle-error res args)) (ac-dcd-parse-output prefix)))))
;; Still try to get any useful input.
(ac-dcd-parse-output prefix))))
(defsubst ac-dcd-cursor-position () (defsubst ac-dcd-cursor-position ()
"Get cursor position to pass to dcd-client. "Get cursor position to pass to dcd-client.
@ -281,7 +279,7 @@ When the symbol is not a function, returns nothing"
(forward-char 2) (forward-char 2)
(delete-char -3) (delete-char -3)
) )
@ -302,7 +300,7 @@ When the symbol is not a function, returns nothing"
(end-of-line) (end-of-line)
(backward-sexp) (backward-sexp)
(re-search-backward (rx (or bol " ")))) (re-search-backward (rx (or bol " "))))
(setq res (buffer-substring (setq res (buffer-substring
(point) (point)
(progn (progn
@ -334,7 +332,7 @@ It returns a list of calltip candidates."
"Format the calltip to yasnippet style. "Format the calltip to yasnippet style.
This function should be called at *dcd-output* buf." This function should be called at *dcd-output* buf."
(let (beg end) (let (beg end)
(save-excursion (save-excursion
(setq end (point)) (setq end (point))
(setq beg (progn (setq beg (progn
(backward-sexp) (backward-sexp)
@ -347,7 +345,7 @@ This function should be called at *dcd-output* buf."
;;remove parenthesis ;;remove parenthesis
(setq str (substring str 1 (- (length str) 1))) (setq str (substring str 1 (- (length str) 1)))
(setq yasstr (setq yasstr
(mapconcat (mapconcat
(lambda (s) "format each args to yasnippet style" (concat "${" s "}")) (lambda (s) "format each args to yasnippet style" (concat "${" s "}"))
@ -377,7 +375,7 @@ This function should be called at *dcd-output* buf."
;; struct constructor calltip expansion ;; struct constructor calltip expansion
(defsubst ac-dcd-replace-this-to-struct-name (struct-name) (defsubst ac-dcd-replace-this-to-struct-name (struct-name)
"When to complete struct constructor calltips, dcd-client outputs candidates which begins with\"this\", "When to complete struct constructor calltips, dcd-client outputs candidates which begins with\"this\",
so I have to replace it with struct name." so I have to replace it with struct name."
(while (search-forward "this" nil t)) (while (search-forward "this" nil t))
(replace-match struct-name)) (replace-match struct-name))
@ -412,7 +410,7 @@ so I have to replace it with struct name."
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward (rx (and (not (any "\\")) (submatch "\\n"))) nil t) (while (re-search-forward (rx (and (not (any "\\")) (submatch "\\n"))) nil t)
(replace-match "\n" nil nil nil 1)) (replace-match "\n" nil nil nil 1))
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward (rx (and (not (any "\\")) (submatch "\\n"))) nil t) (while (re-search-forward (rx (and (not (any "\\")) (submatch "\\n"))) nil t)
(replace-match "\n" nil nil nil 1)) (replace-match "\n" nil nil nil 1))
@ -425,7 +423,7 @@ so I have to replace it with struct name."
(defun ac-dcd-get-ddoc (pos) (defun ac-dcd-get-ddoc (pos)
"Get document with `dcd-client --doc'. `POS' is cursor position." "Get document with `dcd-client --doc'. `POS' is cursor position."
(save-buffer) (save-buffer)
(let ((args (let ((args
(append (append
(ac-dcd-build-complete-args (ac-dcd-cursor-position)) (ac-dcd-build-complete-args (ac-dcd-cursor-position))
'("-d") '("-d")
@ -485,7 +483,7 @@ so I have to replace it with struct name."
(defun ac-dcd-goto-definition () (defun ac-dcd-goto-definition ()
"Goto declaration of symbol at point." "Goto declaration of symbol at point."
(interactive) (interactive)
(save-buffer) (save-buffer)
(ac-dcd-call-process-for-symbol-declaration (point)) (ac-dcd-call-process-for-symbol-declaration (point))
(let* ((data (ac-dcd-parse-output-for-get-symbol-declaration)) (let* ((data (ac-dcd-parse-output-for-get-symbol-declaration))
(file (car data)) (file (car data))
@ -508,7 +506,7 @@ so I have to replace it with struct name."
(defun ac-dcd-call-process-for-symbol-declaration (pos) (defun ac-dcd-call-process-for-symbol-declaration (pos)
"Get location of symbol declaration with `dcd-client --symbolLocation'. "Get location of symbol declaration with `dcd-client --symbolLocation'.
`POS' is cursor position." `POS' is cursor position."
(let ((args (let ((args
(append (append
(ac-dcd-build-complete-args (ac-dcd-cursor-position)) (ac-dcd-build-complete-args (ac-dcd-cursor-position))
'("-l") '("-l")

View File

@ -101,6 +101,8 @@ struct ModuleCache
{ {
foreach (fileName; dirEntries(path, "*.{d,di}", SpanMode.depth)) foreach (fileName; dirEntries(path, "*.{d,di}", SpanMode.depth))
{ {
import std.path: baseName;
if(fileName.baseName.startsWith(".#")) continue;
getSymbolsInModule(fileName); getSymbolsInModule(fileName);
} }
} }