aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Liu2013-04-27 00:44:38 +0800
committerLeo Liu2013-04-27 00:44:38 +0800
commite55d3b0408c33aef72cddb6076617dacbf9ea4c0 (patch)
treeb79535981feee4a5dba8158e3202b68f7b73bc47
parent140ef50c0494870fd6b817f8f9b7e8d2cee81b64 (diff)
downloademacs-e55d3b0408c33aef72cddb6076617dacbf9ea4c0.tar.gz
emacs-e55d3b0408c33aef72cddb6076617dacbf9ea4c0.zip
* progmodes/octave.el (octave-sync-function-file-names): New function.
(octave-mode): Use it in before-save-hook.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/octave.el21
2 files changed, 26 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 290f23a3550..f57bf838cd5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12013-04-26 Leo Liu <sdl.web@gmail.com>
2
3 * progmodes/octave.el (octave-sync-function-file-names): New function.
4 (octave-mode): Use it in before-save-hook.
5
12013-04-26 Stefan Monnier <monnier@iro.umontreal.ca> 62013-04-26 Stefan Monnier <monnier@iro.umontreal.ca>
2 7
3 * emacs-lisp/tabulated-list.el (tabulated-list-mode): Disable undo 8 * emacs-lisp/tabulated-list.el (tabulated-list-mode): Disable undo
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index c5f83a50654..3c24205eb8e 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -626,6 +626,7 @@ including a reproducible test case and send the message."
626 626
627 (add-hook 'completion-at-point-functions 627 (add-hook 'completion-at-point-functions
628 'octave-completion-at-point-function nil t) 628 'octave-completion-at-point-function nil t)
629 (add-hook 'before-save-hook 'octave-sync-function-file-names nil t)
629 (setq-local beginning-of-defun-function 'octave-beginning-of-defun) 630 (setq-local beginning-of-defun-function 'octave-beginning-of-defun)
630 631
631 (easy-menu-add octave-mode-menu)) 632 (easy-menu-add octave-mode-menu))
@@ -1008,6 +1009,26 @@ directory and makes this the current buffer's default directory."
1008 nil 1009 nil
1009 (delete-horizontal-space) 1010 (delete-horizontal-space)
1010 (insert (concat " " octave-continuation-string)))) 1011 (insert (concat " " octave-continuation-string))))
1012
1013(defun octave-sync-function-file-names ()
1014 "Ensure function name agree with function file name.
1015See Info node `(octave)Function Files'."
1016 (interactive)
1017 (save-excursion
1018 (when (and buffer-file-name
1019 (prog2
1020 (goto-char (point-min))
1021 (equal (funcall smie-forward-token-function) "function")
1022 (forward-word -1)))
1023 (let ((file (file-name-sans-extension
1024 (file-name-nondirectory buffer-file-name)))
1025 (func (and (re-search-forward octave-function-header-regexp nil t)
1026 (match-string 3))))
1027 (when (and (not (equal file func))
1028 (yes-or-no-p
1029 "Function name different from file name. Fix? "))
1030 (replace-match file nil nil nil 3))))))
1031
1011 1032
1012;;; Indentation 1033;;; Indentation
1013 1034