(smie-rule-parent octave-block-offset)
;; For (invalid) code between switch and case.
;; (if (smie-parent-p "switch") 4)
- 0))))
+ nil))))
(defun octave-indent-comment ()
"A function for `smie-indent-functions' (which see)."
(back-to-indentation)
(cond
((octave-in-string-or-comment-p) nil)
- ((looking-at-p "\\s<\\{3,\\}")
+ ((looking-at-p "\\(\\s<\\)\\1\\{2,\\}")
0)
;; Exclude %{, %} and %!.
((and (looking-at-p "\\s<\\(?:[^{}!]\\|$\\)")
- (not (looking-at-p "\\s<\\s<")))
+ (not (looking-at-p "\\(\\s<\\)\\1")))
(comment-choose-indent)))))
\f
(setq-local paragraph-ignore-fill-prefix t)
(setq-local fill-paragraph-function 'octave-fill-paragraph)
- ;; Use `smie-auto-fill' after fixing bug#14381.
- (setq-local normal-auto-fill-function 'do-auto-fill)
(setq-local fill-nobreak-predicate
(lambda () (eq (octave-in-string-p) ?')))
- (setq-local comment-line-break-function #'octave-indent-new-comment-line)
+ (add-function :around (local 'comment-line-break-function)
+ #'octave--indent-new-comment-line)
(setq font-lock-defaults '(octave-font-lock-keywords))
(when (and inferior-octave-startup-file
(file-exists-p inferior-octave-startup-file))
(format "source (\"%s\");\n" inferior-octave-startup-file))))
- (insert-before-markers
- (concat
- (if inferior-octave-output-list
- (concat (mapconcat
- 'identity inferior-octave-output-list "\n")
- "\n"))
- inferior-octave-output-string))
+ (when inferior-octave-output-list
+ (insert-before-markers
+ (mapconcat 'identity inferior-octave-output-list "\n")))
;; And finally, everything is back to normal.
(set-process-filter proc 'comint-output-filter)
;; Just in case, to be sure a cd in the startup file
;; won't have detrimental effects.
(inferior-octave-resync-dirs)
- ;; A trick to get the prompt highlighted.
+ ;; Generate a proper prompt, which is critical to
+ ;; `comint-history-isearch-backward-regexp'. Bug#14433.
(comint-send-string proc "\n")))
(defvar inferior-octave-completion-table
(setq list (cdr list)))
(set-process-filter proc filter))))
+(defvar inferior-octave-directory-tracker-resync nil)
+(make-variable-buffer-local 'inferior-octave-directory-tracker-resync)
+
(defun inferior-octave-directory-tracker (string)
"Tracks `cd' commands issued to the inferior Octave process.
Use \\[inferior-octave-resync-dirs] to resync if Emacs gets confused."
+ (when inferior-octave-directory-tracker-resync
+ (setq inferior-octave-directory-tracker-resync nil)
+ (inferior-octave-resync-dirs))
(cond
((string-match "^[ \t]*cd[ \t;]*$" string)
(cd "~"))
((string-match "^[ \t]*cd[ \t]+\\([^ \t\n;]*\\)[ \t\n;]*" string)
- (with-demoted-errors ; in case directory doesn't exist
- (cd (substring string (match-beginning 1) (match-end 1)))))))
+ (condition-case err
+ (cd (match-string 1 string))
+ (error (setq inferior-octave-directory-tracker-resync t)
+ (message "%s: `%s'"
+ (error-message-string err)
+ (match-string 1 string)))))))
(defun inferior-octave-resync-dirs ()
"Resync the buffer's idea of the current directory.
;;; Indentation
(defun octave-indent-new-comment-line (&optional soft)
+ ;; FIXME: C-M-j should probably be bound globally to a function like
+ ;; this one.
"Break Octave line at point, continuing comment if within one.
Insert `octave-continuation-string' before breaking the line
unless inside a list. Signal an error if within a single-quoted
string."
(interactive)
+ (funcall comment-line-break-function soft))
+
+(defun octave--indent-new-comment-line (orig &rest args)
(cond
((octave-in-comment-p) nil)
((eq (octave-in-string-p) ?')
(unless (and (cadr (syntax-ppss))
(eq (char-after (cadr (syntax-ppss))) ?\())
(insert " " octave-continuation-string))))
- (indent-new-comment-line soft)
+ (apply orig args)
(indent-according-to-mode))
(define-obsolete-function-alias
;; Make 'See also' clickable
(with-syntax-table octave-mode-syntax-table
(when (re-search-forward "^\\s-*See also:" nil t)
- (while (re-search-forward "\\_<\\(?:\\sw\\|\\s_\\)+\\_>" nil t)
- (make-text-button (match-beginning 0)
- (match-end 0)
- :type 'octave-help-function))))
+ (let ((end (save-excursion (re-search-forward "^\\s-*$" nil t))))
+ (while (re-search-forward "\\_<\\(?:\\sw\\|\\s_\\)+\\_>" end t)
+ (make-text-button (match-beginning 0)
+ ;; If the match ends with . exclude it.
+ (if (eq (char-before (match-end 0)) ?.)
+ (1- (match-end 0))
+ (match-end 0))
+ :type 'octave-help-function)))))
(octave-help-mode)))))
(defcustom octave-source-directories nil