From 7144c62778d5c4700de4c9a12f9165423b12864e Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 10 Apr 2013 02:31:17 +0900 Subject: [PATCH] * lisp/progmodes/sh-script.el: Implement `sh-mode' own `add-log-current-defun-function'. (sh-current-defun-name): New function. (sh-mode): Use the function. Fixes: debbugs:14112 --- lisp/ChangeLog | 7 +++++++ lisp/progmodes/sh-script.el | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8eafcfacd98..01887620250 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2013-04-10 Masatake YAMATO + + * progmodes/sh-script.el: Implement `sh-mode' own + `add-log-current-defun-function' (bug#14112). + (sh-current-defun-name): New function. + (sh-mode): Use the function. + 2013-04-09 Bastien Guerry * simple.el (choose-completion-string): Fix docstring (bug#14163). diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 8f1954402e5..e197f9cfabe 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -353,6 +353,28 @@ See `sh-feature' and `imenu-generic-expression'." :group 'sh-script :version "20.4") +(defun sh-current-defun-name () + "Find the name of function or variable at point. +For use in `add-log-current-defun-function'." + (save-excursion + (end-of-line) + (when (re-search-backward + (concat "\\(?:" + ;; function FOO + ;; function FOO() + "^\\s-*function\\s-+\\\([[:alpha:]_][[:alnum:]_]*\\)\\s-*\\(?:()\\)?" + "\\)\\|\\(?:" + ;; FOO() + "^\\s-*\\([[:alpha:]_][[:alnum:]_]*\\)\\s-*()" + "\\)\\|\\(?:" + ;; FOO= + "^\\([[:alpha:]_][[:alnum:]_]*\\)=" + "\\)") + nil t) + (or (match-string-no-properties 1) + (match-string-no-properties 2) + (match-string-no-properties 3))))) + (defvar sh-shell-variables nil "Alist of shell variable names that should be included in completion. These are used for completion in addition to all the variables named @@ -1533,6 +1555,7 @@ with your script for an edit-interpret-debug cycle." (setq-local skeleton-newline-indent-rigidly t) (setq-local defun-prompt-regexp (concat "^\\(function[ \t]\\|[[:alnum:]]+[ \t]+()[ \t]+\\)")) + (setq-local add-log-current-defun-function #'sh-current-defun-name) ;; Parse or insert magic number for exec, and set all variables depending ;; on the shell thus determined. (sh-set-shell -- 2.39.2