2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/sh/autoload.el -*- lexical-binding: t; -*-
|
2017-02-19 18:57:16 -05:00
|
|
|
|
|
|
|
;;;###autoload
|
2017-06-20 15:34:10 +02:00
|
|
|
(defun +sh--match-variables-in-quotes (limit)
|
2017-02-19 18:57:16 -05:00
|
|
|
"Search for variables in double-quoted strings bounded by LIMIT."
|
2017-06-20 15:34:10 +02:00
|
|
|
(with-syntax-table sh-mode-syntax-table
|
|
|
|
(let (res)
|
|
|
|
(while
|
|
|
|
(and (setq res
|
|
|
|
(re-search-forward
|
2017-10-17 23:55:48 +02:00
|
|
|
"[^\\]\\(\\$\\)\\({.+?}\\|\\<[a-zA-Z0-9_]+\\|[@*#!]\\)"
|
2017-06-20 15:34:10 +02:00
|
|
|
limit t))
|
|
|
|
(not (eq (nth 3 (syntax-ppss)) ?\"))))
|
|
|
|
res)))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
|
|
|
;;;###autoload
|
2017-06-20 15:34:10 +02:00
|
|
|
(defun +sh--match-command-subst-in-quotes (limit)
|
|
|
|
"Search for variables in double-quoted strings bounded by LIMIT."
|
|
|
|
(with-syntax-table sh-mode-syntax-table
|
|
|
|
(let (res)
|
|
|
|
(while
|
|
|
|
(and (setq res
|
2017-10-17 23:55:48 +02:00
|
|
|
(re-search-forward "[^\\]\\(\\$(.+?)\\|`.+?`\\)"
|
2017-06-20 15:34:10 +02:00
|
|
|
limit t))
|
|
|
|
(not (eq (nth 3 (syntax-ppss)) ?\"))))
|
|
|
|
res)))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2017-06-08 11:47:56 +02:00
|
|
|
(defvar sh-shell-file)
|
2017-02-19 18:57:16 -05:00
|
|
|
;;;###autoload
|
2019-02-18 01:56:38 -05:00
|
|
|
(defun +sh/open-repl ()
|
2017-02-19 18:57:16 -05:00
|
|
|
"Open a shell REPL."
|
2019-10-04 21:25:52 -04:00
|
|
|
(interactive)
|
2023-02-26 19:14:11 +09:00
|
|
|
(require 'sh-script)
|
2017-02-19 18:57:16 -05:00
|
|
|
(let* ((dest-sh (symbol-name sh-shell))
|
|
|
|
(sh-shell-file dest-sh))
|
|
|
|
(sh-shell-process t)
|
|
|
|
(with-current-buffer "*shell*"
|
2019-10-04 21:25:52 -04:00
|
|
|
(rename-buffer (format "*shell [%s]*" dest-sh))
|
|
|
|
(current-buffer))))
|
2021-02-23 19:22:22 -05:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +sh-lookup-documentation-handler ()
|
|
|
|
"Look up documentation in `man' or `woman'."
|
|
|
|
(interactive)
|
2023-02-23 00:06:04 -05:00
|
|
|
(require 'man)
|
|
|
|
(let ((input (Man-default-man-entry)))
|
|
|
|
(if (executable-find "man")
|
|
|
|
(let* ((input (Man-translate-references input))
|
|
|
|
(buffer (Man-getpage-in-background input)))
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
(switch-to-buffer buffer)))
|
|
|
|
(woman input t)
|
|
|
|
(current-buffer))))
|