Giter Club home page Giter Club logo

modern-sh's Introduction

Emacs Logo GitHub license Sponsor MELPA

Modern sh

An Emacs minor mode for editing shell script.

Features

  • Modern syntax highlighting
  • Auto format on save
  • Code navigation (using imenu)
  • Go to definition (using ctags)
  • REPL

Installation

Using MELPA

This package can be obtain from MELPA or MELPA Stable. The master branch is continuously deployed to MELPA, and released versions are deployed to MELPA Stable.

M-x package-install [RET] modern-sh [RET]

(require 'modern-sh)
(define-key modern-sh-mode-map (kbd "<f6>")  'modern-sh-menu)
(add-hook 'sh-mode-hook #'modern-sh-mode)

modern-sh's People

Contributors

damon-kwok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

modern-sh's Issues

Non file buffer issue

Hello,

thanks for the package. I notice that there is an edge case to the use of your package: you assume that the buffer is related to a file. On my side, I tend to use, a lot, org-mode to store snippets. Therefore, the package load as the code snippet is not linked to a shell script file.

So in case that is useful, I solved this by wrapping the activating this way:

  (use-package modern-sh
    :ensure t
    :hook (sh-mode . embed-modern-sh-mode-toggle)
    :bind
    (:map modern-sh-mode-map
          ("C-<f6>"  . modern-sh-menu))
    :init
    (defun embed-modern-sh-mode-toggle ()
        (when (buffer-file-name)
          (modern-sh-mode))))

Ctags cannot open tag file : Permission denied

  • Version: 27.2
  • Platform: WSL2 Ubuntu 20.04

I dont this is a bug per this package, but I have not used ctags before and do not know where this could be trying to access. I am getting the error ctags:ctags: cannot open tag file : Permission denied when I am saving a shell script. Hopefully you can point me in the right direction and thank you for the great package!

Issue in modern-sh after save hook

  • Version: 27.2
  • Platform: Ubuntu 20.04 (WSL2)

Was freezing when calling the after save-hook and rebuilding the tags. I wonder if there is more convenient location to call this. Are tags meant to go through files and basically update when there is a new file? Removing the build call in the hook seems to have helped the problem but it kinda defeats the purpose. Any thoughts? Would love to help

Debugger entered--Lisp error: (quit)
  call-process("/usr/bin/zsh" nil t nil "-c" "ctags -e -R . ")
  call-process-shell-command("ctags -e -R . " nil t)
  #f(compiled-function (command &optional output-buffer error-buffer) "Execute string COMMAND in inferior shell; display output, if any.\nWith prefix argument, insert the COMMAND's output at point.\n\nInteractively, prompt for COMMAND in the minibuffer.\nIf `shell-command-prompt-show-cwd' is non-nil, show the current\ndirectory in the prompt.\n\nIf COMMAND ends in `&', execute it asynchronously.\nThe output appears in the buffer `*Async Shell Command*'.\nThat buffer is in shell mode.  You can also use\n`async-shell-command' that automatically adds `&'.\n\nOtherwise, COMMAND is executed synchronously.  The output appears in\nthe buffer `*Shell Command Output*'.  If the output is short enough to\ndisplay in the echo area (which is determined by the variables\n`resize-mini-windows' and `max-mini-window-height'), it is shown\nthere, but it is nonetheless available in buffer `*Shell Command\nOutput*' even though that buffer is not automatically displayed.\n\nTo specify a coding system for converting non-ASCII characters\nin the shell command output, use \\[universal-coding-system-argument] before this command.\n\nNoninteractive callers can specify coding systems by binding\n`coding-system-for-read' and `coding-system-for-write'.\n\nThe optional second argument OUTPUT-BUFFER, if non-nil,\nsays to put the output in some other buffer.\nIf OUTPUT-BUFFER is a buffer or buffer name, erase that buffer\nand insert the output there; a non-nil value of\n`shell-command-dont-erase-buffer' prevents the buffer from being\nerased.  If OUTPUT-BUFFER is not a buffer and not nil (which happens\ninteractively when the prefix argument is given), insert the\noutput in current buffer after point leaving mark after it.  This\ncannot be done asynchronously.\n\nThe user option `shell-command-dont-erase-buffer', which see, controls\nwhether the output buffer is erased and where to put point after\nthe shell command.\n\nIf the command terminates without error, but generates output,\nand you did not specify \"insert it in the current buffer\",\nthe output can be displayed in the echo area or in its buffer.\nIf the output is short enough to display in the echo area\n(determined by the variable `max-mini-window-height' if\n`resize-mini-windows' is non-nil), it is shown there.\nOtherwise, the buffer containing the output is displayed.\n\nIf there is output and an error, and you did not specify \"insert it\nin the current buffer\", a message about the error goes at the end\nof the output.\n\nIf the optional third argument ERROR-BUFFER is non-nil, it is a buffer\nor buffer name to which to direct the command's standard error output.\nIf it is nil, error output is mingled with regular output.\nIn an interactive call, the variable `shell-command-default-error-buffer'\nspecifies the value of ERROR-BUFFER.\n\nIn Elisp, you will often be better served by calling `call-process' or\n`start-process' directly, since they offer more control and do not\nimpose the use of a shell (with its need to quote arguments)." (interactive #f(compiled-function () #<bytecode 0x4dc54c5>)) #<bytecode 0x1fe739969e3f>)("ctags -e -R . " t nil)
  shell-command--shell-command-with-editor-mode(#f(compiled-function (command &optional output-buffer error-buffer) "Execute string COMMAND in inferior shell; display output, if any.\nWith prefix argument, insert the COMMAND's output at point.\n\nInteractively, prompt for COMMAND in the minibuffer.\nIf `shell-command-prompt-show-cwd' is non-nil, show the current\ndirectory in the prompt.\n\nIf COMMAND ends in `&', execute it asynchronously.\nThe output appears in the buffer `*Async Shell Command*'.\nThat buffer is in shell mode.  You can also use\n`async-shell-command' that automatically adds `&'.\n\nOtherwise, COMMAND is executed synchronously.  The output appears in\nthe buffer `*Shell Command Output*'.  If the output is short enough to\ndisplay in the echo area (which is determined by the variables\n`resize-mini-windows' and `max-mini-window-height'), it is shown\nthere, but it is nonetheless available in buffer `*Shell Command\nOutput*' even though that buffer is not automatically displayed.\n\nTo specify a coding system for converting non-ASCII characters\nin the shell command output, use \\[universal-coding-system-argument] before this command.\n\nNoninteractive callers can specify coding systems by binding\n`coding-system-for-read' and `coding-system-for-write'.\n\nThe optional second argument OUTPUT-BUFFER, if non-nil,\nsays to put the output in some other buffer.\nIf OUTPUT-BUFFER is a buffer or buffer name, erase that buffer\nand insert the output there; a non-nil value of\n`shell-command-dont-erase-buffer' prevents the buffer from being\nerased.  If OUTPUT-BUFFER is not a buffer and not nil (which happens\ninteractively when the prefix argument is given), insert the\noutput in current buffer after point leaving mark after it.  This\ncannot be done asynchronously.\n\nThe user option `shell-command-dont-erase-buffer', which see, controls\nwhether the output buffer is erased and where to put point after\nthe shell command.\n\nIf the command terminates without error, but generates output,\nand you did not specify \"insert it in the current buffer\",\nthe output can be displayed in the echo area or in its buffer.\nIf the output is short enough to display in the echo area\n(determined by the variable `max-mini-window-height' if\n`resize-mini-windows' is non-nil), it is shown there.\nOtherwise, the buffer containing the output is displayed.\n\nIf there is output and an error, and you did not specify \"insert it\nin the current buffer\", a message about the error goes at the end\nof the output.\n\nIf the optional third argument ERROR-BUFFER is non-nil, it is a buffer\nor buffer name to which to direct the command's standard error output.\nIf it is nil, error output is mingled with regular output.\nIn an interactive call, the variable `shell-command-default-error-buffer'\nspecifies the value of ERROR-BUFFER.\n\nIn Elisp, you will often be better served by calling `call-process' or\n`start-process' directly, since they offer more control and do not\nimpose the use of a shell (with its need to quote arguments)." (interactive #f(compiled-function () #<bytecode 0x449b3f5>)) #<bytecode 0x1fe739969e3f>) "ctags -e -R . " t)
  apply(shell-command--shell-command-with-editor-mode #f(compiled-function (command &optional output-buffer error-buffer) "Execute string COMMAND in inferior shell; display output, if any.\nWith prefix argument, insert the COMMAND's output at point.\n\nInteractively, prompt for COMMAND in the minibuffer.\nIf `shell-command-prompt-show-cwd' is non-nil, show the current\ndirectory in the prompt.\n\nIf COMMAND ends in `&', execute it asynchronously.\nThe output appears in the buffer `*Async Shell Command*'.\nThat buffer is in shell mode.  You can also use\n`async-shell-command' that automatically adds `&'.\n\nOtherwise, COMMAND is executed synchronously.  The output appears in\nthe buffer `*Shell Command Output*'.  If the output is short enough to\ndisplay in the echo area (which is determined by the variables\n`resize-mini-windows' and `max-mini-window-height'), it is shown\nthere, but it is nonetheless available in buffer `*Shell Command\nOutput*' even though that buffer is not automatically displayed.\n\nTo specify a coding system for converting non-ASCII characters\nin the shell command output, use \\[universal-coding-system-argument] before this command.\n\nNoninteractive callers can specify coding systems by binding\n`coding-system-for-read' and `coding-system-for-write'.\n\nThe optional second argument OUTPUT-BUFFER, if non-nil,\nsays to put the output in some other buffer.\nIf OUTPUT-BUFFER is a buffer or buffer name, erase that buffer\nand insert the output there; a non-nil value of\n`shell-command-dont-erase-buffer' prevents the buffer from being\nerased.  If OUTPUT-BUFFER is not a buffer and not nil (which happens\ninteractively when the prefix argument is given), insert the\noutput in current buffer after point leaving mark after it.  This\ncannot be done asynchronously.\n\nThe user option `shell-command-dont-erase-buffer', which see, controls\nwhether the output buffer is erased and where to put point after\nthe shell command.\n\nIf the command terminates without error, but generates output,\nand you did not specify \"insert it in the current buffer\",\nthe output can be displayed in the echo area or in its buffer.\nIf the output is short enough to display in the echo area\n(determined by the variable `max-mini-window-height' if\n`resize-mini-windows' is non-nil), it is shown there.\nOtherwise, the buffer containing the output is displayed.\n\nIf there is output and an error, and you did not specify \"insert it\nin the current buffer\", a message about the error goes at the end\nof the output.\n\nIf the optional third argument ERROR-BUFFER is non-nil, it is a buffer\nor buffer name to which to direct the command's standard error output.\nIf it is nil, error output is mingled with regular output.\nIn an interactive call, the variable `shell-command-default-error-buffer'\nspecifies the value of ERROR-BUFFER.\n\nIn Elisp, you will often be better served by calling `call-process' or\n`start-process' directly, since they offer more control and do not\nimpose the use of a shell (with its need to quote arguments)." (interactive #f(compiled-function () #<bytecode 0x601297d>)) #<bytecode 0x1fe739969e3f>) ("ctags -e -R . " t))
  shell-command("ctags -e -R . " t)
  shell-command-to-string("ctags -e -R . ")
  (message "ctags:%s" (shell-command-to-string ctags-params))
  (let* ((oldir default-directory) (ctags-params (concat "ctags -e -R . "))) (setq default-directory (modern-sh-project-root)) (message "ctags:%s" (shell-command-to-string ctags-params)) (modern-sh-load-tags) (setq default-directory oldir))
  modern-sh-build-tags()
  (if (not (executable-find "ctags")) (message "Could not locate executable '%s'" "ctags") (modern-sh-build-tags))
  (progn (modern-sh-format-buffer) (if (not (executable-find "ctags")) (message "Could not locate executable '%s'" "ctags") (modern-sh-build-tags)))
  (if (eq major-mode 'sh-mode) (progn (modern-sh-format-buffer) (if (not (executable-find "ctags")) (message "Could not locate executable '%s'" "ctags") (modern-sh-build-tags))))
  modern-sh-after-save-hook()
  run-hooks(after-save-hook)
  basic-save-buffer(t)
  save-buffer(1)
  funcall-interactively(save-buffer 1)
  call-interactively(save-buffer nil nil)
  command-execute(save-buffer)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.