aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fürmetz <fuermetz@mailbox.org>2018-11-21 23:10:59 +0100
committerGitHub <noreply@github.com>2018-11-21 23:10:59 +0100
commit954ab9ffafbe7e7b7cb9f30ca55e9314f20268e2 (patch)
tree5aa60dadba701edfe9dde4a228bf67d01d1926f4
parent2ecc871bfe5c1d9dde0ba62d454095bfa64ebd91 (diff)
parent3f3cda0bb5ea45474f5bdbd3f4410b113f8f5614 (diff)
Merge pull request #35 from deb0ch/vterm-install
Fix auto-install
-rw-r--r--CMakeLists.txt1
-rw-r--r--vterm.el55
2 files changed, 31 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a170a8..521ce54 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,7 @@ set_target_properties(vterm-module PROPERTIES
C_STANDARD 99
POSITION_INDEPENDENT_CODE ON
PREFIX ""
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}
)
# Link with libvterm
diff --git a/vterm.el b/vterm.el
index 2d209f7..3a0a354 100644
--- a/vterm.el
+++ b/vterm.el
@@ -7,25 +7,25 @@
;;; Code:
+(defvar vterm-install-buffer-name " *Install vterm"
+ "Name of the buffer used for compiling vterm-module.")
+
+;;;###autoload
(defun vterm-module-compile ()
"This function compiles the vterm-module."
(interactive)
- (let ((buffer (get-buffer-create " *Install vterm"))
- (default-directory (file-name-directory (locate-library "vterm"))))
- (make-process
- :name "build-vterm-module"
- :buffer buffer
- :command '("sh" "-c" "mkdir -p build; cd build; cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..; make")
- :stderr buffer
- :sentinel (lambda (process status)
- (if (equal status "finished\n")
- (progn (let ((buffer (process-buffer process)))
- (bury-buffer buffer)
- (when-let ((window (get-buffer-window buffer)))
- (delete-window window)))
- (message "Sucessfully compiled the emacs-libvterm module."))
- (message "Compilation of libvterm has failed."))))
- (pop-to-buffer buffer)))
+ (let ((default-directory (file-name-directory (locate-library "vterm"))))
+ (unless (file-executable-p (concat default-directory "vterm-module.so" ))
+ (let* ((buffer (get-buffer-create vterm-install-buffer-name))
+ (status (call-process "sh" nil buffer t "-c"
+ "mkdir -p build; \
+ cd build; \
+ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..; \
+ make")))
+ (if (eq status 0)
+ (message "Compilation of emacs-libvterm module succeeded")
+ (pop-to-buffer vterm-install-buffer-name)
+ (error "Compilation of emacs-libvterm module failed!"))))))
(when (boundp 'vterm-install)
(vterm-module-compile))
@@ -135,7 +135,7 @@ for different shell. "
(make-variable-buffer-local 'vterm--process)
(define-derived-mode vterm-mode fundamental-mode "VTerm"
- "Mayor mode for vterm buffer."
+ "Major mode for vterm buffer."
(buffer-disable-undo)
(setq vterm--term (vterm--new (window-body-height)
(window-body-width)
@@ -147,14 +147,19 @@ for different shell. "
(add-hook 'window-size-change-functions #'vterm--window-size-change t t)
(let ((process-environment (append '("TERM=xterm") process-environment)))
- (setq vterm--process (make-process
- :name "vterm"
- :buffer (current-buffer)
- :command `("/bin/sh" "-c" ,(format "stty -nl sane iutf8 rows %d columns %d >/dev/null && exec %s" (window-body-height) (window-body-width) vterm-shell))
- :coding 'no-conversion
- :connection-type 'pty
- :filter #'vterm--filter
- :sentinel (when vterm-exit-hook #'vterm--sentinel)))))
+ (setq vterm--process
+ (make-process
+ :name "vterm"
+ :buffer (current-buffer)
+ :command `("/bin/sh" "-c"
+ ,(format "stty -nl sane iutf8 rows %d columns %d >/dev/null && exec %s"
+ (window-body-height)
+ (window-body-width)
+ vterm-shell))
+ :coding 'no-conversion
+ :connection-type 'pty
+ :filter #'vterm--filter
+ :sentinel (when vterm-exit-hook #'vterm--sentinel)))))
;; Keybindings
(define-key vterm-mode-map [tab] #'vterm--self-insert)