Emacs: finished sh skels

master
Pierre Neidhardt 2014-02-13 18:40:02 +01:00
parent 60e8c60425
commit e3dee12875
2 changed files with 36 additions and 6 deletions

View File

@ -60,7 +60,10 @@
(define-abbrev-table 'select-tags-table-mode-abbrev-table '())
(define-abbrev-table 'sh-mode-abbrev-table '())
(define-abbrev-table 'sh-mode-abbrev-table
'(
("null" "" sh-redirect-to-null 0)
))
(define-abbrev-table 'snippet-mode-abbrev-table '())

View File

@ -31,8 +31,8 @@ otherwise use 'sh-shell-file'."
(define-skeleton sh-for
"Insert a for loop. See `sh-feature'. This overrides vanilla function."
nil
"for " (setq str (skeleton-read "Index variable: " "i"))
"Index variable: "
> "for " str | "i"
'(setq v1 (skeleton-read "Index values: " ""))
(unless (string= v1 "")
(concat " in " v1))
@ -54,7 +54,6 @@ otherwise use 'sh-shell-file'."
}
")
(define-skeleton sh-getopts
"Insert a getops prototype."
nil
@ -92,9 +91,37 @@ if [ $# -eq 0 ]; then
fi
")
(define-skeleton sh-cmd
(define-skeleton sh-command
"Insert a line that executes if command is found in path."
"Command name: "
"command -v " @ str " >/dev/null 2>&1 && " @ _)
> "command -v " @ str " >/dev/null 2>&1 && " @ _)
(define-skeleton sh-ifcommand
"Insert a test to check if command is found in path."
"Command name: "
> "if command -v " @ str " >/dev/null 2>&1; then" \n
> @ _ \n
"fi" > \n)
(define-skeleton sh-command-or-die
"Insert a line that quits if command is not found in path."
"Command name: "
> "if ! command -v " @ str " >/dev/null 2>&1; then" \n
> "echo '" str " not found in PATH. Exiting.' >&2" \n
> "exit 1" \n
"fi" > \n)
(define-skeleton sh-redirect-to-null
"Insert a null redirection."
nil
">/dev/null 2>&1")
(define-skeleton sh-while-read
"Insert a while read loop."
nil
> "while IFS= read -r i; do" \n
> @ _ \n
> "done <<EOF" \n
> "EOF" \n)
(provide 'mode-shell)