[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r112397: * progmodes/octave.el (octav
From: |
Leo Liu |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r112397: * progmodes/octave.el (octave-sync-function-file-names): New function. |
Date: |
Sat, 27 Apr 2013 00:44:38 +0800 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 112397
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Sat 2013-04-27 00:44:38 +0800
message:
* progmodes/octave.el (octave-sync-function-file-names): New function.
(octave-mode): Use it in before-save-hook.
modified:
lisp/ChangeLog
lisp/progmodes/octave.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-04-26 14:47:07 +0000
+++ b/lisp/ChangeLog 2013-04-26 16:44:38 +0000
@@ -1,3 +1,8 @@
+2013-04-26 Leo Liu <address@hidden>
+
+ * progmodes/octave.el (octave-sync-function-file-names): New function.
+ (octave-mode): Use it in before-save-hook.
+
2013-04-26 Stefan Monnier <address@hidden>
* emacs-lisp/tabulated-list.el (tabulated-list-mode): Disable undo
=== modified file 'lisp/progmodes/octave.el'
--- a/lisp/progmodes/octave.el 2013-04-26 14:34:26 +0000
+++ b/lisp/progmodes/octave.el 2013-04-26 16:44:38 +0000
@@ -626,6 +626,7 @@
(add-hook 'completion-at-point-functions
'octave-completion-at-point-function nil t)
+ (add-hook 'before-save-hook 'octave-sync-function-file-names nil t)
(setq-local beginning-of-defun-function 'octave-beginning-of-defun)
(easy-menu-add octave-mode-menu))
@@ -1008,6 +1009,26 @@
nil
(delete-horizontal-space)
(insert (concat " " octave-continuation-string))))
+
+(defun octave-sync-function-file-names ()
+ "Ensure function name agree with function file name.
+See Info node `(octave)Function Files'."
+ (interactive)
+ (save-excursion
+ (when (and buffer-file-name
+ (prog2
+ (goto-char (point-min))
+ (equal (funcall smie-forward-token-function) "function")
+ (forward-word -1)))
+ (let ((file (file-name-sans-extension
+ (file-name-nondirectory buffer-file-name)))
+ (func (and (re-search-forward octave-function-header-regexp nil t)
+ (match-string 3))))
+ (when (and (not (equal file func))
+ (yes-or-no-p
+ "Function name different from file name. Fix? "))
+ (replace-match file nil nil nil 3))))))
+
;;; Indentation
- [Emacs-diffs] /srv/bzr/emacs/trunk r112397: * progmodes/octave.el (octave-sync-function-file-names): New function.,
Leo Liu <=