From: Leo Liu Date: Tue, 21 May 2013 09:43:14 +0000 (+0800) Subject: Simplify auto fill in Octave mode and some small improvements X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~229^2~17 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9cc3e83f9db0958931b358cda25741459fb733c5;p=emacs.git Simplify auto fill in Octave mode and some small improvements --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f723ba346d6..57d055ece22 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2013-05-21 Leo Liu + + * progmodes/octave.el (octave-auto-fill): Remove. + (octave-indent-new-comment-line): Improve. + (octave-mode): Use auto fill mode through + comment-line-break-function and fill-nobreak-predicate + (octave-goto-function-definition): Support DEFUN_DLD. + (octave-beginning-of-defun): Small Tweak + (octave-help): Show parent directory. + 2013-05-21 Glenn Morris * files.el (dired-unmark): diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 4f1e6c2cc14..76172d5b59a 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -540,11 +540,11 @@ definitions can also be stored in files and used in batch mode." (setq-local paragraph-separate paragraph-start) (setq-local paragraph-ignore-fill-prefix t) (setq-local fill-paragraph-function 'octave-fill-paragraph) - ;; FIXME: Why disable it? - ;; (setq-local adaptive-fill-regexp nil) - ;; Again, this is not a property of the language, don't set it here. - ;; (setq fill-column 72) - (setq-local normal-auto-fill-function 'octave-auto-fill) + + ;; Use `smie-auto-fill' after fixing bug#14381. + (setq-local normal-auto-fill-function 'do-auto-fill) + (setq-local fill-nobreak-predicate #'octave-in-string-p) + (setq-local comment-line-break-function #'octave-indent-new-comment-line) (setq font-lock-defaults '(octave-font-lock-keywords)) @@ -946,7 +946,7 @@ directory and makes this the current buffer's default directory." (or done (goto-char (point-min))))))) (pcase (file-name-extension (buffer-file-name)) (`"cc" (funcall search - "\\_ arg 0) (/= orig (point))) (setq arg (1- arg))) (forward-sexp (- arg)) + (and (< arg 0) (forward-sexp -1)) (/= orig (point)))) - -;;; Filling -(defun octave-auto-fill () - "Perform auto-fill in Octave mode. -Returns nil if no feasible place to break the line could be found, and t -otherwise." - (let (fc give-up) - (if (or (null (setq fc (current-fill-column))) - (save-excursion - (beginning-of-line) - (and auto-fill-inhibit-regexp - (octave-looking-at-kw auto-fill-inhibit-regexp)))) - nil ; Can't do anything - (if (and (not (octave-in-comment-p)) - (> (current-column) fc)) - (setq fc (- fc (+ (length octave-continuation-string) 1)))) - (while (and (not give-up) (> (current-column) fc)) - (let* ((opoint (point)) - (fpoint - (save-excursion - (move-to-column (+ fc 1)) - (skip-chars-backward "^ \t\n") - ;; If we're at the beginning of the line, break after - ;; the first word - (if (bolp) - (re-search-forward "[ \t]" opoint t)) - ;; If we're in a comment line, don't break after the - ;; comment chars - (if (save-excursion - (skip-syntax-backward " <") - (bolp)) - (re-search-forward "[ \t]" (line-end-position) - 'move)) - ;; If we're not in a comment line and just ahead the - ;; continuation string, don't break here. - (if (and (not (octave-in-comment-p)) - (looking-at - (concat "\\s-*" - (regexp-quote - octave-continuation-string) - "\\s-*$"))) - (end-of-line)) - (skip-chars-backward " \t") - (point)))) - (if (save-excursion - (goto-char fpoint) - (not (or (bolp) (eolp)))) - (let ((prev-column (current-column))) - (if (save-excursion - (skip-chars-backward " \t") - (= (point) fpoint)) - (progn - (octave-maybe-insert-continuation-string) - (indent-new-comment-line t)) - (save-excursion - (goto-char fpoint) - (octave-maybe-insert-continuation-string) - (indent-new-comment-line t))) - (if (>= (current-column) prev-column) - (setq give-up t))) - (setq give-up t)))) - (not give-up)))) - (defun octave-fill-paragraph (&optional _arg) "Fill paragraph of Octave code, handling Octave comments." ;; FIXME: difference with generic fill-paragraph: @@ -1354,11 +1296,10 @@ otherwise." (and (= (current-column) cfc) (eolp))) (forward-line 1) (if (not (eolp)) (insert " ")) - (or (octave-auto-fill) + (or (do-auto-fill) (forward-line 1)))) t))) - ;;; Completions (defun octave-completion-at-point () @@ -1658,10 +1599,14 @@ if ismember(exist(\"%s\"), [2 3 5 103]) print_usage(\"%s\") endif\n" (when (re-search-forward "from the file \\(.*\\)$" (line-end-position) t) - (let ((file (match-string 1))) + (let* ((file (match-string 1)) + (dir (file-name-directory + (directory-file-name (file-name-directory file))))) (replace-match "" nil nil nil 1) (insert "`") - (help-insert-xref-button (file-name-nondirectory file) + ;; Include the parent directory which may be regarded as + ;; the category for the FN. + (help-insert-xref-button (file-relative-name file dir) 'octave-help-file fn) (insert "'"))) ;; Make 'See also' clickable