From 2ec12cb0f025b5476b8a1d7cacac2456bd5c1115 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Mon, 29 Apr 2013 12:37:36 +0800 Subject: [PATCH] * progmodes/octave.el (inferior-octave-startup-hook): Obsolete. (inferior-octave-startup): Remove inferior-octave-startup-hook. (octave-function-file-comment): Fix typo. (octave-sync-function-file-names): Use read-char-choice. --- lisp/ChangeLog | 7 +++++++ lisp/progmodes/octave.el | 44 ++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8055106bd31..be33eb5d085 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2013-04-29 Leo Liu + + * progmodes/octave.el (inferior-octave-startup-hook): Obsolete. + (inferior-octave-startup): Remove inferior-octave-startup-hook. + (octave-function-file-comment): Fix typo. + (octave-sync-function-file-names): Use read-char-choice. + 2013-04-28 Jay Belanger * calc/calc.el (math-normalize): Don't set `math-normalize-error' diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index b8fbe6a90a7..e171a860e8f 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -641,7 +641,8 @@ the regular expression `comint-prompt-regexp', a buffer local variable." (defvar inferior-octave-output-string nil) (defvar inferior-octave-receive-in-progress nil) -(defvar inferior-octave-startup-hook nil) +(define-obsolete-variable-alias 'inferior-octave-startup-hook + 'inferior-octave-mode-hook "24.4") (defvar inferior-octave-complete-impossible nil "Non-nil means that `inferior-octave-complete' is impossible.") @@ -785,8 +786,6 @@ startup file, `~/.emacs-octave'." ;; And finally, everything is back to normal. (set-process-filter proc 'inferior-octave-output-filter) - (run-hooks 'inferior-octave-startup-hook) - (run-hooks 'inferior-octave-startup-hook) ;; Just in case, to be sure a cd in the startup file ;; won't have detrimental effects. (inferior-octave-resync-dirs))) @@ -966,7 +965,7 @@ The value is (START END NAME-START NAME-END) of the function." ;;; First non-copyright comment block (defun octave-function-file-comment () - "Beginnning and end positions of the function file comment." + "Beginning and end positions of the function file comment." (save-excursion (goto-char (point-min)) (let ((bound (progn (forward-comment (point-max)) (point)))) @@ -994,17 +993,32 @@ See Info node `(octave)Function Files'." (pcase-let ((`(,start ,_end ,name-start ,name-end) (octave-function-file-p))) (when (and start name-start) - (let ((func (buffer-substring name-start name-end)) - (file (file-name-sans-extension - (file-name-nondirectory buffer-file-name)))) - (save-excursion - (when (and (not (equal file func)) - (progn - (goto-char name-start) - (yes-or-no-p - "Function name different from file name. Fix? "))) - (delete-region name-start name-end) - (insert file)))))))) + (let* ((func (buffer-substring name-start name-end)) + (file (file-name-sans-extension + (file-name-nondirectory buffer-file-name))) + (help-form (format "\ +a: Use function name `%s' +b: Use file name `%s' +q: Don't fix\n" func file)) + (c (unless (equal file func) + (save-window-excursion + (help-form-show) + (read-char-choice + "Which name to use? (a/b/q) " '(?a ?b ?q)))))) + (pcase c + (`?a (let ((newname (expand-file-name + (concat func (file-name-extension + buffer-file-name t))))) + (when (or (not (file-exists-p newname)) + (yes-or-no-p + (format "Target file %s exists; proceed? " newname))) + (when (file-exists-p buffer-file-name) + (rename-file buffer-file-name newname t)) + (set-visited-file-name newname)))) + (`?b (save-excursion + (goto-char name-start) + (delete-region name-start name-end) + (insert file))))))))) (defun octave-update-function-file-comment (beg end) "Query replace function names in function file comment." -- 2.39.2