cmake-mode.el: Clean up cmake-command-run and add buffername argument

This commit is contained in:
Philipp Möller 2014-01-28 22:57:49 +01:00
parent 2816ffae90
commit 2a1314150e
1 changed files with 13 additions and 30 deletions

View File

@ -266,40 +266,24 @@ the indentation. Otherwise it retains the same position on the line"
;;;###autoload ;;;###autoload
(defun cmake-command-run (type &optional topic) (defun cmake-command-run (type &optional topic buffer)
"Runs the command cmake with the arguments specified. The "Runs the command cmake with the arguments specified. The
optional argument topic will be appended to the argument list." optional argument topic will be appended to the argument list."
(interactive "s") (interactive "s")
(let* ((bufname (concat "*CMake" type (if topic "-") topic "*")) (let* ((bufname (if buffer buffer (concat "*CMake" type (if topic "-") topic "*")))
(buffer (get-buffer bufname)) (buffer (if (get-buffer bufname) (get-buffer bufname) (generate-new-buffer bufname)))
)
(if buffer
(display-buffer buffer 'not-this-window)
;; Buffer doesn't exist. Create it and fill it
(let ((buffer (generate-new-buffer bufname))
(command (concat cmake-mode-cmake-executable " " type " " topic)) (command (concat cmake-mode-cmake-executable " " type " " topic))
;; Turn of resizing of mini-windows for shell-command.
(resize-mini-windows nil)
) )
(message "Running %s" command)
;; We don't want the contents of the shell-command running to the
;; minibuffer, so turn it off. A value of nil means don't automatically
;; resize mini-windows.
(setq resize-mini-windows-save resize-mini-windows)
(setq resize-mini-windows nil)
(shell-command command buffer) (shell-command command buffer)
;; Save the original window, so that we can come back to it later. (save-selected-window
;; save-excursion doesn't seem to work for this.
(setq window (selected-window))
;; We need to select it so that we can apply special modes to it
(select-window (display-buffer buffer 'not-this-window)) (select-window (display-buffer buffer 'not-this-window))
(cmake-mode) (cmake-mode)
(toggle-read-only t) (toggle-read-only t))
;; Restore the original window
(select-window window)
(setq resize-mini-windows resize-mini-windows-save) (setq resize-mini-windows resize-mini-windows-save)
) )
) )
)
)
;;;###autoload ;;;###autoload
(defun cmake-help-list-commands () (defun cmake-help-list-commands ()
@ -327,12 +311,11 @@ optional argument topic will be appended to the argument list."
input)) input))
) )
;;;###autoload ;;;###autoload
(defun cmake-help-command () (defun cmake-help-command ()
"Prints out the help message corresponding to the command the cursor is on." "Prints out the help message corresponding to the command the cursor is on."
(interactive) (interactive)
(cmake-command-run "--help-command" (downcase (cmake-get-topic "command")))) (cmake-command-run "--help-command" (downcase (cmake-get-topic "command")) "*CMake Help*"))
;;;###autoload ;;;###autoload