GNU bug report logs -
#14112
[patch] add-log-current-defun-function for sh-mode
Previous Next
Reported by: Masatake YAMATO <yamato <at> redhat.com>
Date: Mon, 1 Apr 2013 08:30:08 UTC
Severity: normal
Tags: patch
Fixed in version 24.4
Done: Glenn Morris <rgm <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14112 in the body.
You can then email your comments to 14112 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14112
; Package
emacs
.
(Mon, 01 Apr 2013 08:30:10 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Masatake YAMATO <yamato <at> redhat.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 01 Apr 2013 08:30:14 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
This is a feature request with a patch. Please, review the
patch and install it to the official source tree if appreciated.
The patch comes from two parts:
1. definition of add-log-current-defun-function for sh-mode
2. Test case
Mode own add-log-current-defun-function is not defined in sh-mode.
So wc cannot pick up a function name with C-x 4 a.
This patch implement it.
------------------------------------------------------------
revno: 112201
committer: Masatake YAMATO <yamato <at> redhat.com>
branch nick: emacs-sh-add-log
timestamp: Mon 2013-04-01 17:22:03 +0900
message:
* lisp/progmodes/sh-script.el (sh-current-defun-name): New function.
* automated/add-log-tests.el: New file.
diff:
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog 2013-04-01 08:13:33 +0000
+++ lisp/ChangeLog 2013-04-01 08:22:03 +0000
@@ -1,5 +1,9 @@
2013-04-01 Masatake YAMATO <yamato <at> localhost.localdomain>
+ * progmodes/sh-script.el (sh-current-defun-name): New function.
+
+2013-04-01 Masatake YAMATO <yamato <at> localhost.localdomain>
+
* progmodes/sh-script.el (sh-imenu-generic-expression): Handle
function names with a single character.
=== modified file 'lisp/progmodes/sh-script.el'
--- lisp/progmodes/sh-script.el 2013-04-01 08:13:33 +0000
+++ lisp/progmodes/sh-script.el 2013-04-01 08:22:03 +0000
@@ -353,6 +353,29 @@
: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 +1556,7 @@
(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
=== modified file 'test/ChangeLog'
--- test/ChangeLog 2013-04-01 08:13:33 +0000
+++ test/ChangeLog 2013-04-01 08:22:03 +0000
@@ -1,5 +1,9 @@
2013-04-01 Masatake YAMATO <yamato <at> redhat.com>
+ * automated/add-log-tests.el: New file.
+
+2013-04-01 Masatake YAMATO <yamato <at> redhat.com>
+
* automated/imenu-tests.el: New file.
2013-03-30 Fabián Ezequiel Gallina <fabian <at> anue.biz>
=== added file 'test/automated/add-log-tests.el'
--- test/automated/add-log-tests.el 1970-01-01 00:00:00 +0000
+++ test/automated/add-log-tests.el 2013-04-01 08:22:03 +0000
@@ -0,0 +1,84 @@
+;;; add-log-tests.el --- Test suite for add-log.
+
+;; Copyright (C) 2013 Free Software Foundation, Inc.
+
+;; Author: Masatake YAMATO <yamato <at> redhat.com>
+;; Keywords: vc tools
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'add-log)
+
+(defmacro add-log-current-defun-deftest (name doc major-mode
+ content marker expected-defun)
+ "Generate an ert test for mode-own `add-log-current-defun-function'.
+Run `add-log-current-defun' at the point where MARKER specifies in a
+buffer which content is CONTENT under MAJOR-MODE. Then it compares the
+result with EXPECTED-DEFUN."
+ (let ((xname (intern (concat "add-log-current-defun-test-"
+ (symbol-name name)
+ ))))
+ `(ert-deftest ,xname ()
+ ,doc
+ (with-temp-buffer
+ (insert ,content)
+ (goto-char (point-min))
+ (funcall ',major-mode)
+ (should (equal (when (search-forward ,marker nil t)
+ (replace-match "" nil t)
+ (add-log-current-defun))
+ ,expected-defun))))))
+
+(add-log-current-defun-deftest
+ sh-func1
+ "Test sh-current-defun-name can find function."
+ sh-mode "
+function foo
+{
+ ><
+}" "><" "foo")
+
+(add-log-current-defun-deftest
+ sh-func2
+ "Test sh-current-defun-name can find function."
+ sh-mode "
+foo()
+{
+ ><
+}" "><" "foo")
+
+(add-log-current-defun-deftest
+ sh-func3
+ "Test sh-current-defun-name can find function."
+ sh-mode "
+function foo()
+{
+ ><
+}" "><" "foo")
+
+(add-log-current-defun-deftest
+ sh-var
+ "Test sh-current-defun-name can find variabe definision."
+ sh-mode "
+PATH=a:/ab:/usr/abc
+DIR=/pr><oc"
+"><" "DIR")
+
+(provide 'add-log-tests)
+
+;;; add-log-tests.el ends here
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14112
; Package
emacs
.
(Thu, 04 Apr 2013 02:08:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 14112 <at> debbugs.gnu.org (full text, mbox):
> This is a feature request with a patch. Please, review the
> patch and install it to the official source tree if appreciated.
The patch looks good. I se you don't yet have write access.
Do you want me to give you access so you can install those
patches yourself? That would save me time,
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14112
; Package
emacs
.
(Fri, 05 Apr 2013 11:01:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 14112 <at> debbugs.gnu.org (full text, mbox):
>> This is a feature request with a patch. Please, review the
>> patch and install it to the official source tree if appreciated.
>
> The patch looks good.
Thank you for reviewing.
> I se you don't yet have write access.
> Do you want me to give you access so you can install those
> patches yourself? That would save me time,
I don't want take your time for installing my small patch.
Please, re-give me write access to bzr repository.
My account is "masatake".
I must learn the usage of bzr.
Masatake YAMATO
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14112
; Package
emacs
.
(Fri, 05 Apr 2013 13:32:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 14112 <at> debbugs.gnu.org (full text, mbox):
> Please, re-give me write access to bzr repository.
Great, thank you.
Actually, I can't do that without you first requesting membership in the
"emacs" group from your Savannah account.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14112
; Package
emacs
.
(Fri, 05 Apr 2013 14:26:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 14112 <at> debbugs.gnu.org (full text, mbox):
>> Please, re-give me write access to bzr repository.
>
> Great, thank you.
> Actually, I can't do that without you first requesting membership in the
> "emacs" group from your Savannah account.
>
>
> Stefan
I've submitted the requesting.
Regard,
Masatake YAMATO
bug marked as fixed in version 24.4, send any further explanations to
14112 <at> debbugs.gnu.org and Masatake YAMATO <yamato <at> redhat.com>
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Mon, 22 Apr 2013 01:52:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 20 May 2013 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 11 years and 357 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.