* progmodes/octave.el (octave-sync-function-file-names): New function.
(octave-mode): Use it in before-save-hook.
This commit is contained in:
parent
140ef50c04
commit
e55d3b0408
2 changed files with 26 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2013-04-26 Leo Liu <sdl.web@gmail.com>
|
||||
|
||||
* progmodes/octave.el (octave-sync-function-file-names): New function.
|
||||
(octave-mode): Use it in before-save-hook.
|
||||
|
||||
2013-04-26 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* emacs-lisp/tabulated-list.el (tabulated-list-mode): Disable undo
|
||||
|
|
|
@ -626,6 +626,7 @@ including a reproducible test case and send the message."
|
|||
|
||||
(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 @@ directory and makes this the current buffer's default directory."
|
|||
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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue