Now on revision 112387. ------------------------------------------------------------ revno: 112387 committer: Leo Liu branch nick: trunk timestamp: Fri 2013-04-26 12:16:37 +0800 message: * progmodes/octave.el (octave-submit-bug-report): Obsolete. (octave-mode, inferior-octave-mode): Use setq-local. (octave-not-in-string-or-comment-p): Renamed to octave-in-string-or-comment-p. (octave-in-comment-p, octave-in-string-p) (octave-in-string-or-comment-p): Replace defsubst with defun. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-04-25 21:20:17 +0000 +++ lisp/ChangeLog 2013-04-26 04:16:37 +0000 @@ -1,3 +1,12 @@ +2013-04-26 Leo Liu + + * progmodes/octave.el (octave-submit-bug-report): Obsolete. + (octave-mode, inferior-octave-mode): Use setq-local. + (octave-not-in-string-or-comment-p): Renamed to + octave-in-string-or-comment-p. + (octave-in-comment-p, octave-in-string-p) + (octave-in-string-or-comment-p): Replace defsubst with defun. + 2013-04-25 Paul Eggert * Makefile.in (distclean): Remove $(lisp)/loaddefs.el~. === modified file 'lisp/progmodes/octave.el' --- lisp/progmodes/octave.el 2013-04-25 16:23:56 +0000 +++ lisp/progmodes/octave.el 2013-04-26 04:16:37 +0000 @@ -1,4 +1,4 @@ -;;; octave.el --- editing octave source files under emacs +;;; octave.el --- editing octave source files under emacs -*- lexical-binding: t; -*- ;; Copyright (C) 1997, 2001-2013 Free Software Foundation, Inc. @@ -39,9 +39,8 @@ :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) :group 'languages) -(defconst octave-maintainer-address - "Kurt Hornik , bug-gnu-emacs@gnu.org" - "Current maintainer of the Emacs Octave package.") +(define-obsolete-function-alias 'octave-submit-bug-report + 'report-emacs-bug "24.4") (define-abbrev-table 'octave-abbrev-table (mapcar (lambda (e) (append e '(nil 0 t))) @@ -585,53 +584,48 @@ (smie-setup octave-smie-grammar #'octave-smie-rules :forward-token #'octave-smie-forward-token :backward-token #'octave-smie-backward-token) - (set (make-local-variable 'smie-indent-basic) 'octave-block-offset) + (setq-local smie-indent-basic 'octave-block-offset) - (set (make-local-variable 'smie-blink-matching-triggers) - (cons ?\; smie-blink-matching-triggers)) + (setq-local smie-blink-matching-triggers + (cons ?\; smie-blink-matching-triggers)) (unless octave-blink-matching-block (remove-hook 'post-self-insert-hook #'smie-blink-matching-open 'local)) - (set (make-local-variable 'electric-indent-chars) - (cons ?\; electric-indent-chars)) + (setq-local electric-indent-chars + (cons ?\; electric-indent-chars)) ;; IIUC matlab-mode takes the opposite approach: it makes RET insert ;; a ";" at those places where it's correct (i.e. outside of parens). - (set (make-local-variable 'electric-layout-rules) '((?\; . after))) + (setq-local electric-layout-rules '((?\; . after))) - (set (make-local-variable 'comment-start) octave-comment-start) - (set (make-local-variable 'comment-end) "") + (setq-local comment-start octave-comment-start) + (setq-local comment-end "") ;; Don't set it here: it's not really a property of the language, ;; just a personal preference of the author. - ;; (set (make-local-variable 'comment-column) 32) - (set (make-local-variable 'comment-start-skip) "\\s<+\\s-*") - (set (make-local-variable 'comment-add) 1) + ;; (setq-local comment-column 32) + (setq-local comment-start-skip "\\s<+\\s-*") + (setq-local comment-add 1) - (set (make-local-variable 'parse-sexp-ignore-comments) t) - (set (make-local-variable 'paragraph-start) - (concat "\\s-*$\\|" page-delimiter)) - (set (make-local-variable 'paragraph-separate) paragraph-start) - (set (make-local-variable 'paragraph-ignore-fill-prefix) t) - (set (make-local-variable 'fill-paragraph-function) 'octave-fill-paragraph) + (setq-local parse-sexp-ignore-comments t) + (setq-local paragraph-start (concat "\\s-*$\\|" page-delimiter)) + (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? - ;; (set (make-local-variable 'adaptive-fill-regexp) nil) + ;; (setq-local adaptive-fill-regexp nil) ;; Again, this is not a property of the language, don't set it here. - ;; (set (make-local-variable 'fill-column) 72) - (set (make-local-variable 'normal-auto-fill-function) 'octave-auto-fill) - - (set (make-local-variable 'font-lock-defaults) - '(octave-font-lock-keywords)) - - (set (make-local-variable 'syntax-propertize-function) - #'octave-syntax-propertize-function) - - (set (make-local-variable 'imenu-generic-expression) - octave-mode-imenu-generic-expression) - (set (make-local-variable 'imenu-case-fold-search) nil) + ;; (setq fill-column 72) + (setq-local normal-auto-fill-function 'octave-auto-fill) + + (setq font-lock-defaults '(octave-font-lock-keywords)) + + (setq-local syntax-propertize-function #'octave-syntax-propertize-function) + + (setq imenu-generic-expression octave-mode-imenu-generic-expression) + (setq imenu-case-fold-search nil) (add-hook 'completion-at-point-functions 'octave-completion-at-point-function nil t) - (set (make-local-variable 'beginning-of-defun-function) - 'octave-beginning-of-defun) + (setq-local beginning-of-defun-function 'octave-beginning-of-defun) (easy-menu-add octave-mode-menu)) @@ -738,21 +732,20 @@ mode-line-process '(":%s") local-abbrev-table octave-abbrev-table) - (set (make-local-variable 'comment-start) octave-comment-start) - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'comment-column) 32) - (set (make-local-variable 'comment-start-skip) octave-comment-start-skip) - - (set (make-local-variable 'font-lock-defaults) - '(inferior-octave-font-lock-keywords nil nil)) - - (set (make-local-variable 'info-lookup-mode) 'octave-mode) + (setq-local comment-start octave-comment-start) + (setq-local comment-end "") + (setq comment-column 32) + (setq-local comment-start-skip octave-comment-start-skip) + + (setq font-lock-defaults '(inferior-octave-font-lock-keywords nil nil)) + + (setq info-lookup-mode 'octave-mode) (setq comint-input-ring-file-name (or (getenv "OCTAVE_HISTFILE") "~/.octave_hist") comint-input-ring-size (or (getenv "OCTAVE_HISTSIZE") 1024)) - (set (make-local-variable 'comint-dynamic-complete-functions) - inferior-octave-dynamic-complete-functions) + (setq-local comint-dynamic-complete-functions + inferior-octave-dynamic-complete-functions) (add-hook 'comint-input-filter-functions 'inferior-octave-directory-tracker nil t) (comint-read-input-ring t)) @@ -989,19 +982,17 @@ ;;; Miscellaneous useful functions -(defsubst octave-in-comment-p () - "Return t if point is inside an Octave comment." +(defun octave-in-comment-p () + "Return non-nil if point is inside an Octave comment." (nth 4 (syntax-ppss))) -(defsubst octave-in-string-p () - "Return t if point is inside an Octave string." +(defun octave-in-string-p () + "Return non-nil if point is inside an Octave string." (nth 3 (syntax-ppss))) -(defsubst octave-not-in-string-or-comment-p () - "Return t if point is not inside an Octave string or comment." - (let ((pps (syntax-ppss))) - (not (or (nth 3 pps) (nth 4 pps))))) - +(defun octave-in-string-or-comment-p () + "Return non-nil if point is inside an Octave string or comment." + (nth 8 (syntax-ppss))) (defun octave-looking-at-kw (regexp) "Like `looking-at', but sets `case-fold-search' nil." @@ -1149,8 +1140,8 @@ (while (and (/= arg 0) (setq found (re-search-backward "\\_" inc))) - (if (octave-not-in-string-or-comment-p) - (setq arg (- arg inc)))) + (unless (octave-in-string-or-comment-p) + (setq arg (- arg inc)))) (if found (progn (and (< inc 0) (goto-char (match-beginning 0))) @@ -1330,7 +1321,7 @@ "Insert an Octave function skeleton. Prompt for the function's name, arguments and return values (to be entered without parens)." - (let* ((defname (substring (buffer-name) 0 -2)) + (let* ((defname (file-name-sans-extension (buffer-name))) (name (read-string (format "Function name (default %s): " defname) nil nil defname)) (args (read-string "Arguments: ")) @@ -1450,26 +1441,7 @@ "\n"))) (mapconcat 'identity inferior-octave-output-list "\n"))) (terpri))) - -;;; Bug reporting -(defun octave-submit-bug-report () - "Submit a bug report on the Emacs Octave package via mail." - (interactive) - (require 'reporter) - (and - (y-or-n-p "Do you want to submit a bug report? ") - (reporter-submit-bug-report - octave-maintainer-address - (concat "Emacs version " emacs-version) - (list - 'octave-blink-matching-block - 'octave-block-offset - 'octave-comment-char - 'octave-continuation-offset - 'octave-continuation-string - 'octave-send-echo-input - 'octave-send-line-auto-forward - 'octave-send-show-buffer)))) + (provide 'octave) ;;; octave.el ends here ------------------------------------------------------------ revno: 112386 author: Andrew Cohen committer: Katsumi Yamaoka branch nick: trunk timestamp: Fri 2013-04-26 02:08:43 +0000 message: lisp/gnus/gnus-msg.el (gnus-inews-insert-gcc): Re-order conditional to work for string values of 'gcc-self diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2013-04-24 22:07:21 +0000 +++ lisp/gnus/ChangeLog 2013-04-26 02:08:43 +0000 @@ -1,3 +1,8 @@ +2013-04-25 Andrew Cohen + + * gnus-msg.el (gnus-inews-insert-gcc): Re-order conditional to work for + string values of 'gcc-self. Thanks to Saroj Thirumalai. + 2013-04-24 Andrew Cohen * nnir.el (nnir-close-group): Make sure we are in the right group. === modified file 'lisp/gnus/gnus-msg.el' --- lisp/gnus/gnus-msg.el 2013-04-12 15:17:47 +0000 +++ lisp/gnus/gnus-msg.el 2013-04-26 02:08:43 +0000 @@ -1719,8 +1719,8 @@ (group (when group (gnus-group-decoded-name group))) (var (or gnus-outgoing-message-group gnus-message-archive-group)) (gcc-self-val - (and group (gnus-group-find-parameter group 'gcc-self) - (not (gnus-virtual-group-p group)))) + (and group (not (gnus-virtual-group-p group)) + (gnus-group-find-parameter group 'gcc-self))) result (groups (cond ------------------------------------------------------------ revno: 112385 committer: Paul Eggert branch nick: trunk timestamp: Thu 2013-04-25 14:20:17 -0700 message: * Makefile.in (distclean): Remove $(lisp)/loaddefs.el~. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-04-25 17:39:44 +0000 +++ lisp/ChangeLog 2013-04-25 21:20:17 +0000 @@ -1,3 +1,7 @@ +2013-04-25 Paul Eggert + + * Makefile.in (distclean): Remove $(lisp)/loaddefs.el~. + 2013-04-25 Bastien Guerry * textmodes/remember.el (remember-data-directory) === modified file 'lisp/Makefile.in' --- lisp/Makefile.in 2013-01-02 16:13:04 +0000 +++ lisp/Makefile.in 2013-04-25 21:20:17 +0000 @@ -433,7 +433,7 @@ cd $(lisp); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc $(AUTOGENEL) distclean: - -rm -f ./Makefile + -rm -f ./Makefile $(lisp)/loaddefs.el~ maintainer-clean: distclean bootstrap-clean ------------------------------------------------------------ revno: 112384 committer: Bastien Guerry branch nick: trunk timestamp: Thu 2013-04-25 19:39:44 +0200 message: * textmodes/remember.el (remember-data-directory) (remember-directory-file-name-format): Fix custom types. Thanks to Glenn Morris for reporting these problems and for the fixes. diff: === modified file 'etc/NEWS' --- etc/NEWS 2013-04-24 21:02:44 +0000 +++ etc/NEWS 2013-04-25 17:39:44 +0000 @@ -101,6 +101,12 @@ * Changes in Specialized Modes and Packages in Emacs 24.4 +** `remember' can now store notes in separates files +You can use the new function `remember-store-in-files' within the +`remember-handler-functions' option. + +See `remember-data-directory' and `remember-directory-file-name-format' +for new options related to this function. ** `ido-decorations' has been slightly extended to give a bit more control. ** More packages look for ~/.emacs.d/ additionally to ~/.. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-04-25 16:23:56 +0000 +++ lisp/ChangeLog 2013-04-25 17:39:44 +0000 @@ -1,3 +1,8 @@ +2013-04-25 Bastien Guerry + + * textmodes/remember.el (remember-data-directory) + (remember-directory-file-name-format): Fix custom types. + 2013-04-25 Leo Liu * progmodes/octave.el (octave-completion-at-point-function): Make === modified file 'lisp/textmodes/remember.el' --- lisp/textmodes/remember.el 2013-04-24 14:35:59 +0000 +++ lisp/textmodes/remember.el 2013-04-25 17:39:44 +0000 @@ -432,12 +432,14 @@ (defcustom remember-data-directory "~/remember" "The directory in which to store remember data as files." - :type 'file + :type 'directory + :version "24.4" :group 'remember) (defcustom remember-directory-file-name-format "%Y-%m-%d_%T-%z" "Format string for the file name in which to store unprocessed data." - :type 'file + :type 'string + :version "24.4" :group 'remember) (defun remember-store-in-files () ------------------------------------------------------------ revno: 112383 committer: Leo Liu branch nick: trunk timestamp: Fri 2013-04-26 00:23:56 +0800 message: * progmodes/octave.el (octave-completion-at-point-function): Make use of inferior octave process. (octave-initialize-completions): Remove. (inferior-octave-completion-table): New function. (inferior-octave-completion-at-point): Use it. (octave-completion-alist): Remove. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-04-25 16:07:33 +0000 +++ lisp/ChangeLog 2013-04-25 16:23:56 +0000 @@ -1,3 +1,12 @@ +2013-04-25 Leo Liu + + * progmodes/octave.el (octave-completion-at-point-function): Make + use of inferior octave process. + (octave-initialize-completions): Remove. + (inferior-octave-completion-table): New function. + (inferior-octave-completion-at-point): Use it. + (octave-completion-alist): Remove. + 2013-04-25 Stefan Monnier * progmodes/opascal.el: Use font-lock and syntax-propertize. === modified file 'lisp/progmodes/octave.el' --- lisp/progmodes/octave.el 2013-04-25 14:51:08 +0000 +++ lisp/progmodes/octave.el 2013-04-25 16:23:56 +0000 @@ -330,12 +330,6 @@ :type 'string :group 'octave) -(defvar octave-completion-alist nil - "Alist of Octave symbols for completion in Octave mode. -Each element looks like (VAR . VAR), where the car and cdr are the same -symbol (an Octave command or variable name). -Currently, only builtin variables can be completed.") - (defvar octave-mode-imenu-generic-expression (list ;; Functions @@ -639,8 +633,7 @@ (set (make-local-variable 'beginning-of-defun-function) 'octave-beginning-of-defun) - (easy-menu-add octave-mode-menu) - (octave-initialize-completions)) + (easy-menu-add octave-mode-menu)) (defcustom inferior-octave-program "octave" @@ -874,6 +867,15 @@ ;; won't have detrimental effects. (inferior-octave-resync-dirs))) +(defun inferior-octave-completion-table () + (unless inferior-octave-complete-impossible + (completion-table-dynamic + (lambda (command) + (inferior-octave-send-list-and-digest + (list (concat "completion_matches (\"" command "\");\n"))) + (sort (delete-dups inferior-octave-output-list) + 'string-lessp))))) + (defun inferior-octave-completion-at-point () "Return the data to complete the Octave symbol at point." (let* ((end (point)) @@ -887,15 +889,7 @@ "Your Octave does not have `completion_matches'. " "Please upgrade to version 2.X.")) nil) - (t - (list - start end - (completion-table-dynamic - (lambda (command) - (inferior-octave-send-list-and-digest - (list (concat "completion_matches (\"" command "\");\n"))) - (sort (delete-dups inferior-octave-output-list) - 'string-lessp)))))))) + (t (list start end (inferior-octave-completion-table)))))) (define-obsolete-function-alias 'inferior-octave-complete 'completion-at-point "24.1") @@ -1296,14 +1290,6 @@ ;;; Completions -(defun octave-initialize-completions () - "Create an alist for Octave completions." - (if octave-completion-alist - () - (setq octave-completion-alist - (append octave-reserved-words - octave-text-functions - octave-variables)))) (defun octave-completion-at-point-function () "Find the text to complete and the corresponding table." @@ -1313,7 +1299,12 @@ ;; Extend region past point, if applicable. (save-excursion (skip-syntax-forward "w_") (setq end (point)))) - (list beg end octave-completion-alist))) + (list beg end (or (and inferior-octave-process + (process-live-p inferior-octave-process) + (inferior-octave-completion-table)) + (append octave-reserved-words + octave-text-functions + octave-variables))))) (define-obsolete-function-alias 'octave-complete-symbol 'completion-at-point "24.1") ------------------------------------------------------------ revno: 112382 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2013-04-25 12:07:33 -0400 message: * lisp/progmodes/opascal.el: Use font-lock and syntax-propertize. (opascal-mode-syntax-table): New var. (opascal-literal-kind, opascal-is-literal-end) (opascal-literal-token-at): Rewrite. (opascal--literal-start-re, opascal-font-lock-keywords) (opascal--syntax-propertize): New constants. (opascal-font-lock-defaults): Adjust. (opascal-mode): Use them. Set comment- variables as well. (delphi-comment-face, opascal-comment-face, delphi-string-face) (opascal-string-face, delphi-keyword-face, opascal-keyword-face) (delphi-other-face, opascal-other-face): Remove face variables. (opascal-save-state): Remove macro. (opascal-fontifying-progress-step): Remove constant. (opascal--ignore-changes): Remove var. (opascal-set-token-property, opascal-parse-next-literal) (opascal-is-stable-literal, opascal-complete-literal) (opascal-is-literal-start, opascal-face-of) (opascal-parse-region, opascal-parse-region-until-stable) (opascal-fontify-region, opascal-after-change) (opascal-debug-show-is-stable, opascal-debug-unparse-buffer) (opascal-debug-parse-region, opascal-debug-parse-window) (opascal-debug-parse-buffer, opascal-debug-fontify-window) (opascal-debug-fontify-buffer): Remove. (opascal-debug-mode-map): Adjust accordingly. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-04-25 14:51:08 +0000 +++ lisp/ChangeLog 2013-04-25 16:07:33 +0000 @@ -1,3 +1,30 @@ +2013-04-25 Stefan Monnier + + * progmodes/opascal.el: Use font-lock and syntax-propertize. + (opascal-mode-syntax-table): New var. + (opascal-literal-kind, opascal-is-literal-end) + (opascal-literal-token-at): Rewrite. + (opascal--literal-start-re, opascal-font-lock-keywords) + (opascal--syntax-propertize): New constants. + (opascal-font-lock-defaults): Adjust. + (opascal-mode): Use them. Set comment- variables as well. + (delphi-comment-face, opascal-comment-face, delphi-string-face) + (opascal-string-face, delphi-keyword-face, opascal-keyword-face) + (delphi-other-face, opascal-other-face): Remove face variables. + (opascal-save-state): Remove macro. + (opascal-fontifying-progress-step): Remove constant. + (opascal--ignore-changes): Remove var. + (opascal-set-token-property, opascal-parse-next-literal) + (opascal-is-stable-literal, opascal-complete-literal) + (opascal-is-literal-start, opascal-face-of) + (opascal-parse-region, opascal-parse-region-until-stable) + (opascal-fontify-region, opascal-after-change) + (opascal-debug-show-is-stable, opascal-debug-unparse-buffer) + (opascal-debug-parse-region, opascal-debug-parse-window) + (opascal-debug-parse-buffer, opascal-debug-fontify-window) + (opascal-debug-fontify-buffer): Remove. + (opascal-debug-mode-map): Adjust accordingly. + 2013-04-25 Leo Liu Merge octave-mod.el and octave-inf.el into octave.el with some === modified file 'lisp/progmodes/opascal.el' --- lisp/progmodes/opascal.el 2013-04-24 20:44:45 +0000 +++ lisp/progmodes/opascal.el 2013-04-25 16:07:33 +0000 @@ -110,29 +110,6 @@ regardless of where in the line point is when the TAB command is used." :type 'boolean) -(define-obsolete-variable-alias - 'delphi-comment-face 'opascal-comment-face "24.4") -(defcustom opascal-comment-face 'font-lock-comment-face - "Face used to color OPascal comments." - :type 'face) - -(define-obsolete-variable-alias - 'delphi-string-face 'opascal-string-face "24.4") -(defcustom opascal-string-face 'font-lock-string-face - "Face used to color OPascal strings." - :type 'face) - -(define-obsolete-variable-alias - 'delphi-keyword-face 'opascal-keyword-face "24.4") -(defcustom opascal-keyword-face 'font-lock-keyword-face - "Face used to color OPascal keywords." - :type 'face) - -(define-obsolete-variable-alias 'delphi-other-face 'opascal-other-face "24.4") -(defcustom opascal-other-face nil - "Face used to color everything else." - :type '(choice (const :tag "None" nil) face)) - (defconst opascal-directives '(absolute abstract assembler automated cdecl default dispid dynamic export external far forward index inline message name near nodefault @@ -274,6 +251,21 @@ (defconst opascal-leading-spaces-re (concat "^" opascal-spaces-re)) (defconst opascal-word-chars "a-zA-Z0-9_") +(defvar opascal-mode-syntax-table + (let ((st (make-syntax-table))) + ;; Strings. + (modify-syntax-entry ?\" "\"" st) + (modify-syntax-entry ?\' "\"" st) + ;; Comments. + (modify-syntax-entry ?\{ "<" st) + (modify-syntax-entry ?\} ">" st) + (modify-syntax-entry ?\( "()1" st) + (modify-syntax-entry ?\) ")(4" st) + (modify-syntax-entry ?* ". 23b" st) + (modify-syntax-entry ?/ ". 12c" st) + (modify-syntax-entry ?\n "> c" st) + st)) + (defmacro opascal-save-excursion (&rest forms) ;; Executes the forms such that any movements have no effect, including ;; searches. @@ -283,13 +275,6 @@ (deactivate-mark nil)) (progn ,@forms))))) -(defmacro opascal-save-state (&rest forms) - ;; Executes the forms such that any buffer modifications do not have any side - ;; effects beyond the buffer's actual content changes. - `(let ((opascal--ignore-changes t)) - (with-silent-modifications - ,@forms))) - (defsubst opascal-is (element in-set) ;; If the element is in the set, the element cdr is returned, otherwise nil. (memq element in-set)) @@ -347,13 +332,6 @@ ;; Returns the column of the point p. (save-excursion (goto-char p) (current-column))) -(defun opascal-face-of (token-kind) - ;; Returns the face property appropriate for the token kind. - (cond ((opascal-is token-kind opascal-comments) opascal-comment-face) - ((opascal-is token-kind opascal-strings) opascal-string-face) - ((opascal-is token-kind opascal-keywords) opascal-keyword-face) - (opascal-other-face))) - (defvar opascal-progress-last-reported-point nil "The last point at which progress was reported.") @@ -361,8 +339,6 @@ "Number of chars to process before the next parsing progress report.") (defconst opascal-scanning-progress-step 2048 "Number of chars to process before the next scanning progress report.") -(defconst opascal-fontifying-progress-step opascal-scanning-progress-step - "Number of chars to process before the next fontification progress report.") (defun opascal-progress-start () ;; Initializes progress reporting. @@ -400,22 +376,30 @@ (goto-char curr-point) next)) -(defvar opascal--ignore-changes t - "Internal flag to control if the OPascal mode responds to buffer changes. -Defaults to t in case the `opascal-after-change' function is called on a -non-OPascal buffer. Set to nil in OPascal buffers. To override, just do: - (let ((opascal--ignore-changes t)) ...)") - -(defun opascal-set-token-property (from to value) - ;; Like `set-text-properties', except we do not consider this to be a buffer - ;; modification. - (opascal-save-state - (put-text-property from to 'token value))) +(defconst opascal--literal-start-re (regexp-opt '("//" "{" "(*" "'" "\""))) (defun opascal-literal-kind (p) ;; Returns the literal kind the point p is in (or nil if not in a literal). - (if (and (<= (point-min) p) (<= p (point-max))) - (get-text-property p 'token))) + (when (and (<= (point-min) p) (<= p (point-max))) + (save-excursion + (let ((ppss (syntax-ppss p))) + ;; We want to return non-nil when right in front + ;; of a comment/string. + (if (null (nth 8 ppss)) + (when (looking-at opascal--literal-start-re) + (pcase (char-after) + (`?/ 'comment-single-line) + (`?\{ 'comment-multi-line-1) + (`?\( 'comment-multi-line-2) + (`?\' 'string) + (`?\" 'double-quoted-string))) + (if (nth 3 ppss) ;String. + (if (eq (nth 3 ppss) ?\") + 'double-quoted-string 'string) + (pcase (nth 7 ppss) + (`2 'comment-single-line) + (`1 'comment-multi-line-2) + (_ 'comment-multi-line-1)))))))) (defun opascal-literal-start-pattern (literal-kind) ;; Returns the start pattern of the literal kind. @@ -446,87 +430,27 @@ (string . "['\n]") (double-quoted-string . "[\"\n]"))))) -(defun opascal-is-literal-start (p) - ;; True if the point p is at the start point of a (completed) literal. - (let* ((kind (opascal-literal-kind p)) - (pattern (opascal-literal-start-pattern kind))) - (or (null kind) ; Non-literals are considered as start points. - (opascal-looking-at-string p pattern)))) - (defun opascal-is-literal-end (p) ;; True if the point p is at the end point of a (completed) literal. - (let* ((kind (opascal-literal-kind (1- p))) - (pattern (opascal-literal-end-pattern kind))) - (or (null kind) ; Non-literals are considered as end points. - - (and (opascal-looking-at-string (- p (length pattern)) pattern) - (or (not (opascal-is kind opascal-strings)) - ;; Special case: string delimiters are start/end ambiguous. - ;; We have an end only if there is some string content (at - ;; least a starting delimiter). - (not (opascal-is-literal-end (1- p))))) - - ;; Special case: strings cannot span lines. - (and (opascal-is kind opascal-strings) (eq ?\n (char-after (1- p))))))) - -(defun opascal-is-stable-literal (p) - ;; True if the point p marks a stable point. That is, a point outside of a - ;; literal region, inside of a literal region, or adjacent to completed - ;; literal regions. - (let ((at-start (opascal-is-literal-start p)) - (at-end (opascal-is-literal-end p))) - (or (>= p (point-max)) - (and at-start at-end) - (and (not at-start) (not at-end) - (eq (opascal-literal-kind (1- p)) (opascal-literal-kind p)))))) - -(defun opascal-complete-literal (literal-kind limit) - ;; Continues the search for a literal's true end point and returns the - ;; point past the end pattern (if found) or the limit (if not found). - (let ((pattern (opascal-literal-stop-pattern literal-kind))) - (if (not (stringp pattern)) - (error "Invalid literal kind %S" literal-kind) - ;; Search up to the limit. - (re-search-forward pattern limit 'goto-limit-on-fail) - (point)))) - -(defun opascal-parse-next-literal (limit) - ;; Searches for the next literal region (i.e. comment or string) and sets the - ;; the point to its end (or the limit, if not found). The literal region is - ;; marked as such with a text property, to speed up tokenizing during face - ;; coloring and indentation scanning. - (let ((search-start (point))) - (cond ((not (opascal-is-literal-end search-start)) - ;; We are completing an incomplete literal. - (let ((kind (opascal-literal-kind (1- search-start)))) - (opascal-complete-literal kind limit) - (opascal-set-token-property search-start (point) kind))) - - ((re-search-forward - "\\(//\\)\\|\\({\\)\\|\\((\\*\\)\\|\\('\\)\\|\\(\"\\)" - limit 'goto-limit-on-fail) - ;; We found the start of a new literal. Find its end and mark it. - (let ((kind (cond ((match-beginning 1) 'comment-single-line) - ((match-beginning 2) 'comment-multi-line-1) - ((match-beginning 3) 'comment-multi-line-2) - ((match-beginning 4) 'string) - ((match-beginning 5) 'double-quoted-string))) - (start (match-beginning 0))) - (opascal-set-token-property search-start start nil) - (opascal-complete-literal kind limit) - (opascal-set-token-property start (point) kind))) - - ;; Nothing found. Mark it as a non-literal. - ((opascal-set-token-property search-start limit nil))) - (opascal-step-progress (point) "Parsing" opascal-parsing-progress-step))) + (save-excursion + (and (null (nth 8 (syntax-ppss p))) + (nth 8 (syntax-ppss (1- p)))))) (defun opascal-literal-token-at (p) - ;; Returns the literal token surrounding the point p, or nil if none. - (let ((kind (opascal-literal-kind p))) - (when kind - (let ((start (previous-single-property-change (1+ p) 'token)) - (end (next-single-property-change p 'token))) - (opascal-token-of kind (or start (point-min)) (or end (point-max))))))) + "Return the literal token surrounding the point P, or nil if none." + (save-excursion + (let ((ppss (syntax-ppss p))) + (when (or (nth 8 ppss) (looking-at opascal--literal-start-re)) + (let* ((new-start (or (nth 8 ppss) p)) + (new-end (progn + (goto-char new-start) + (condition-case nil + (if (memq (char-after) '(?\' ?\")) + (forward-sexp 1) + (forward-comment 1)) + (scan-error (goto-char (point-max)))) + (point)))) + (opascal-token-of (opascal-literal-kind p) new-start new-end)))))) (defun opascal-point-token-at (p kind) ;; Returns the single character token at the point p. @@ -636,55 +560,6 @@ (opascal-is (opascal-token-kind next-token) '(space newline)))) next-token)) -(defun opascal-parse-region (from to) - ;; Parses the literal tokens in the region. The point is set to "to". - (save-restriction - (widen) - (goto-char from) - (while (< (point) to) - (opascal-parse-next-literal to)))) - -(defun opascal-parse-region-until-stable (from to) - ;; Parses at least the literal tokens in the region. After that, parsing - ;; continues as long as obsolete literal regions are encountered. The point - ;; is set to the encountered stable point. - (save-restriction - (widen) - (opascal-parse-region from to) - (while (not (opascal-is-stable-literal (point))) - (opascal-parse-next-literal (point-max))))) - -(defun opascal-fontify-region (from to &optional verbose) - ;; Colors the text in the region according to OPascal rules. - (opascal-save-excursion - (opascal-save-state - (let ((p from) - (opascal-verbose verbose) - (token nil)) - (opascal-progress-start) - (while (< p to) - ;; Color the token and move past it. - (setq token (opascal-token-at p)) - (add-text-properties - (opascal-token-start token) (opascal-token-end token) - (list 'face (opascal-face-of (opascal-token-kind token)) 'lazy-lock t)) - (setq p (opascal-token-end token)) - (opascal-step-progress p "Fontifying" opascal-fontifying-progress-step)) - (opascal-progress-done))))) - -(defun opascal-after-change (change-start change-end _old-length) - ;; Called when the buffer has changed. Reparses the changed region. - (unless opascal--ignore-changes - (let ((opascal--ignore-changes t)) ; Prevent recursive calls. - (opascal-save-excursion - (opascal-progress-start) - ;; Reparse at least from the token previous to the change to the end of - ;; line after the change. - (opascal-parse-region-until-stable - (opascal-token-start (opascal-token-at (1- change-start))) - (progn (goto-char change-end) (end-of-line) (point))) - (opascal-progress-done))))) - (defun opascal-group-start (from-token) ;; Returns the token that denotes the start of the ()/[] group. (let ((token (opascal-previous-token from-token)) @@ -1552,41 +1427,6 @@ (interactive "r") (opascal-debug-log "String: %S" (buffer-substring from to))) -(defun opascal-debug-show-is-stable () - (interactive) - (opascal-debug-log "stable: %S prev: %S next: %S" - (opascal-is-stable-literal (point)) - (opascal-literal-kind (1- (point))) - (opascal-literal-kind (point)))) - -(defun opascal-debug-unparse-buffer () - (interactive) - (opascal-set-token-property (point-min) (point-max) nil)) - -(defun opascal-debug-parse-region (from to) - (interactive "r") - (let ((opascal-verbose t)) - (opascal-save-excursion - (opascal-progress-start) - (opascal-parse-region from to) - (opascal-progress-done "Parsing done")))) - -(defun opascal-debug-parse-window () - (interactive) - (opascal-debug-parse-region (window-start) (window-end))) - -(defun opascal-debug-parse-buffer () - (interactive) - (opascal-debug-parse-region (point-min) (point-max))) - -(defun opascal-debug-fontify-window () - (interactive) - (opascal-fontify-region (window-start) (window-end) t)) - -(defun opascal-debug-fontify-buffer () - (interactive) - (opascal-fontify-region (point-min) (point-max) t)) - (defun opascal-debug-tokenize-region (from to) (interactive) (opascal-save-excursion @@ -1738,6 +1578,7 @@ (error "Not in a comment") (let* ((start-comment (opascal-comment-block-start comment)) (end-comment (opascal-comment-block-end comment)) + ;; FIXME: Don't abuse global variables like `comment-end/start'. (comment-start (opascal-token-start start-comment)) (comment-end (opascal-token-end end-comment)) (content-start (opascal-comment-content-start start-comment)) @@ -1805,12 +1646,7 @@ ;; Restore our position (goto-char marked-point) - (set-marker marked-point nil) - - ;; React to the entire fill change as a whole. - (opascal-progress-start) - (opascal-parse-region comment-start comment-end) - (opascal-progress-done))))))) + (set-marker marked-point nil))))))) (defun opascal-new-comment-line () "If in a // comment, do a newline, indented such that one is still in the @@ -1839,16 +1675,37 @@ (goto-char end) token))) +(defconst opascal-font-lock-keywords + `(("\\_<\\(function\\|pro\\(cedure\\|gram\\)\\)[ \t]+\\([[:alpha:]][[:alnum:]_]*\\)" + (1 font-lock-keyword-face) (3 font-lock-function-name-face)) + ,(concat "\\_<" (regexp-opt (mapcar #'symbol-name opascal-keywords)) + "\\_>"))) + (defconst opascal-font-lock-defaults - '(nil ; We have our own fontify routine, so keywords don't apply. - t ; Syntactic fontification doesn't apply. + '(opascal-font-lock-keywords + nil ; Syntactic fontification does apply. nil ; Don't care about case since we don't use regexps to find tokens. nil ; Syntax alists don't apply. - nil ; Syntax begin movement doesn't apply - (font-lock-fontify-region-function . opascal-fontify-region) - (font-lock-verbose . opascal-fontifying-progress-step)) + nil ; Syntax begin movement doesn't apply. + ) "OPascal mode font-lock defaults. Syntactic fontification is ignored.") +(defconst opascal--syntax-propertize + (syntax-propertize-rules + ;; The syntax-table settings are too coarse and end up treating /* and (/ + ;; as comment starters. Fix it here by removing the "2" from the syntax + ;; of the second char of such sequences. + ("/\\(\\*\\)" (1 ". 3b")) + ("(\\(\\/\\)" (1 (prog1 ". 1c" (forward-char -1) nil))) + ;; Pascal uses '' and "" rather than \' and \" to escape quotes. + ("''\\|\"\"" (0 (if (save-excursion + (nth 3 (syntax-ppss (match-beginning 0)))) + (string-to-syntax ".") + ;; In case of 3 or more quotes in a row, only advance + ;; one quote at a time. + (forward-char -1) + nil))))) + (defvar opascal-debug-mode-map (let ((kmap (make-sparse-keymap))) (dolist (binding '(("n" opascal-debug-goto-next-token) @@ -1857,14 +1714,7 @@ ("T" opascal-debug-tokenize-buffer) ("W" opascal-debug-tokenize-window) ("g" opascal-debug-goto-point) - ("s" opascal-debug-show-current-string) - ("a" opascal-debug-parse-buffer) - ("w" opascal-debug-parse-window) - ("f" opascal-debug-fontify-window) - ("F" opascal-debug-fontify-buffer) - ("r" opascal-debug-parse-region) - ("c" opascal-debug-unparse-buffer) - ("x" opascal-debug-show-is-stable))) + ("s" opascal-debug-show-current-string))) (define-key kmap (car binding) (cadr binding))) kmap) "Keystrokes for OPascal mode debug commands.") @@ -1914,14 +1764,8 @@ Coloring: - `opascal-comment-face' (default font-lock-comment-face) - Face used to color OPascal comments. - `opascal-string-face' (default font-lock-string-face) - Face used to color OPascal strings. `opascal-keyword-face' (default font-lock-keyword-face) Face used to color OPascal keywords. - `opascal-other-face' (default nil) - Face used to color everything else. Turning on OPascal mode calls the value of the variable `opascal-mode-hook' with no args, if that value is non-nil." @@ -1931,21 +1775,13 @@ (setq-local comment-indent-function #'opascal-indent-line) (setq-local case-fold-search t) (setq-local opascal-progress-last-reported-point nil) - (setq-local opascal--ignore-changes nil) (setq-local font-lock-defaults opascal-font-lock-defaults) (setq-local tab-always-indent opascal-tab-always-indents) - - ;; FIXME: Use syntax-propertize-function to tokenize, maybe? - - ;; We need to keep track of changes to the buffer to determine if we need - ;; to retokenize changed text. - (add-hook 'after-change-functions #'opascal-after-change nil t) - - (opascal-save-excursion - (let ((opascal-verbose t)) - (opascal-progress-start) - (opascal-parse-region (point-min) (point-max)) - (opascal-progress-done)))) + (setq-local syntax-propertize-function opascal--syntax-propertize) + + (setq-local comment-start "// ") + (setq-local comment-start-skip "\\(?://\\|(\\*\\|{\\)[ \t]*") + (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*)\\|}\\)")) (provide 'opascal) ;;; opascal.el ends here ------------------------------------------------------------ revno: 112381 committer: Leo Liu branch nick: trunk timestamp: Thu 2013-04-25 22:51:08 +0800 message: Merge octave-mod.el and octave-inf.el into octave.el with some cleanups. * progmodes/octave.el: New file renamed from octave-mod.el. * progmodes/octave-inf.el: Merged into octave.el. * progmodes/octave-mod.el: Renamed to octave.el. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-04-25 12:01:09 +0000 +++ lisp/ChangeLog 2013-04-25 14:51:08 +0000 @@ -1,3 +1,11 @@ +2013-04-25 Leo Liu + + Merge octave-mod.el and octave-inf.el into octave.el with some + cleanups. + * progmodes/octave.el: New file renamed from octave-mod.el. + * progmodes/octave-inf.el: Merged into octave.el. + * progmodes/octave-mod.el: Renamed to octave.el. + 2013-04-25 Tassilo Horn * textmodes/reftex-vars.el === removed file 'lisp/progmodes/octave-inf.el' --- lisp/progmodes/octave-inf.el 2013-04-20 16:24:04 +0000 +++ lisp/progmodes/octave-inf.el 1970-01-01 00:00:00 +0000 @@ -1,387 +0,0 @@ -;;; octave-inf.el --- running Octave as an inferior Emacs process - -;; Copyright (C) 1997, 2001-2013 Free Software Foundation, Inc. - -;; Author: Kurt Hornik -;; John Eaton -;; Maintainer: FSF -;; Keywords: languages -;; Package: octave-mod - -;; This file is part of GNU Emacs. - -;; GNU Emacs is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; GNU Emacs is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . - -;;; Commentary: - -;;; Code: - -(require 'octave-mod) -(require 'comint) - -(defgroup octave-inferior nil - "Running Octave as an inferior Emacs process." - :group 'octave) - -(defcustom inferior-octave-program "octave" - "Program invoked by `inferior-octave'." - :type 'string - :group 'octave-inferior) - -(defcustom inferior-octave-prompt - "\\(^octave\\(\\|.bin\\|.exe\\)\\(-[.0-9]+\\)?\\(:[0-9]+\\)?\\|^debug\\|^\\)>+ " - "Regexp to match prompts for the inferior Octave process." - :type 'regexp - :group 'octave-inferior) - -(defcustom inferior-octave-startup-file nil - "Name of the inferior Octave startup file. -The contents of this file are sent to the inferior Octave process on -startup." - :type '(choice (const :tag "None" nil) - file) - :group 'octave-inferior) - -(defcustom inferior-octave-startup-args nil - "List of command line arguments for the inferior Octave process. -For example, for suppressing the startup message and using `traditional' -mode, set this to (\"-q\" \"--traditional\")." - :type '(repeat string) - :group 'octave-inferior) - -(defvar inferior-octave-mode-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map comint-mode-map) - (define-key map "\t" 'comint-dynamic-complete) - (define-key map "\M-?" 'comint-dynamic-list-filename-completions) - (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring) - (define-key map [menu-bar inout list-history] - '("List Input History" . inferior-octave-dynamic-list-input-ring)) - ;; FIXME: free C-h so it can do the describe-prefix-bindings. - (define-key map "\C-c\C-h" 'info-lookup-symbol) - map) - "Keymap used in Inferior Octave mode.") - -(defvar inferior-octave-mode-syntax-table - (let ((table (make-syntax-table octave-mode-syntax-table))) - table) - "Syntax table in use in inferior-octave-mode buffers.") - -(defcustom inferior-octave-mode-hook nil - "Hook to be run when Inferior Octave mode is started." - :type 'hook - :group 'octave-inferior) - -(defvar inferior-octave-font-lock-keywords - (list - (cons inferior-octave-prompt 'font-lock-type-face)) - ;; Could certainly do more font locking in inferior Octave ... - "Additional expressions to highlight in Inferior Octave mode.") - - -;;; Compatibility functions -(if (not (fboundp 'comint-line-beginning-position)) - ;; comint-line-beginning-position is defined in Emacs 21 - (defun comint-line-beginning-position () - "Returns the buffer position of the beginning of the line, after any prompt. -The prompt is assumed to be any text at the beginning of the line matching -the regular expression `comint-prompt-regexp', a buffer local variable." - (save-excursion (comint-bol nil) (point)))) - - -(defvar inferior-octave-output-list nil) -(defvar inferior-octave-output-string nil) -(defvar inferior-octave-receive-in-progress nil) - -(defvar inferior-octave-startup-hook nil) - -(defvar inferior-octave-complete-impossible nil - "Non-nil means that `inferior-octave-complete' is impossible.") - -(defvar inferior-octave-has-built-in-variables nil - "Non-nil means that Octave has built-in variables.") - -(defvar inferior-octave-dynamic-complete-functions - '(inferior-octave-completion-at-point comint-filename-completion) - "List of functions called to perform completion for inferior Octave. -This variable is used to initialize `comint-dynamic-complete-functions' -in the Inferior Octave buffer.") - -(defvar info-lookup-mode) - -(define-derived-mode inferior-octave-mode comint-mode "Inferior Octave" - "Major mode for interacting with an inferior Octave process. -Runs Octave as a subprocess of Emacs, with Octave I/O through an Emacs -buffer. - -Entry to this mode successively runs the hooks `comint-mode-hook' and -`inferior-octave-mode-hook'." - (setq comint-prompt-regexp inferior-octave-prompt - mode-line-process '(":%s") - local-abbrev-table octave-abbrev-table) - - (set (make-local-variable 'comment-start) octave-comment-start) - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'comment-column) 32) - (set (make-local-variable 'comment-start-skip) octave-comment-start-skip) - - (set (make-local-variable 'font-lock-defaults) - '(inferior-octave-font-lock-keywords nil nil)) - - (set (make-local-variable 'info-lookup-mode) 'octave-mode) - - (setq comint-input-ring-file-name - (or (getenv "OCTAVE_HISTFILE") "~/.octave_hist") - comint-input-ring-size (or (getenv "OCTAVE_HISTSIZE") 1024)) - (set (make-local-variable 'comint-dynamic-complete-functions) - inferior-octave-dynamic-complete-functions) - (add-hook 'comint-input-filter-functions - 'inferior-octave-directory-tracker nil t) - (comint-read-input-ring t)) - -;;;###autoload -(defun inferior-octave (&optional arg) - "Run an inferior Octave process, I/O via `inferior-octave-buffer'. -This buffer is put in Inferior Octave mode. See `inferior-octave-mode'. - -Unless ARG is non-nil, switches to this buffer. - -The elements of the list `inferior-octave-startup-args' are sent as -command line arguments to the inferior Octave process on startup. - -Additional commands to be executed on startup can be provided either in -the file specified by `inferior-octave-startup-file' or by the default -startup file, `~/.emacs-octave'." - (interactive "P") - (let ((buffer inferior-octave-buffer)) - (get-buffer-create buffer) - (if (comint-check-proc buffer) - () - (with-current-buffer buffer - (comint-mode) - (inferior-octave-startup) - (inferior-octave-mode))) - (if (not arg) - (pop-to-buffer buffer)))) - -;;;###autoload -(defalias 'run-octave 'inferior-octave) - -(defun inferior-octave-startup () - "Start an inferior Octave process." - (let ((proc (comint-exec-1 - (substring inferior-octave-buffer 1 -1) - inferior-octave-buffer - inferior-octave-program - (append (list "-i" "--no-line-editing") - inferior-octave-startup-args)))) - (set-process-filter proc 'inferior-octave-output-digest) - (setq comint-ptyp process-connection-type - inferior-octave-process proc - inferior-octave-output-list nil - inferior-octave-output-string nil - inferior-octave-receive-in-progress t) - - ;; This may look complicated ... However, we need to make sure that - ;; we additional startup code only AFTER Octave is ready (otherwise, - ;; output may be mixed up). Hence, we need to digest the Octave - ;; output to see when it issues a prompt. - (while inferior-octave-receive-in-progress - (accept-process-output inferior-octave-process)) - (goto-char (point-max)) - (set-marker (process-mark proc) (point)) - (insert-before-markers - (concat - (if (not (bobp)) " \n") - (if inferior-octave-output-list - (concat (mapconcat - 'identity inferior-octave-output-list "\n") - "\n")))) - - ;; Find out whether Octave has built-in variables. - (inferior-octave-send-list-and-digest - (list "exist \"LOADPATH\"\n")) - (setq inferior-octave-has-built-in-variables - (string-match "101$" (car inferior-octave-output-list))) - - ;; An empty secondary prompt, as e.g. obtained by '--braindead', - ;; means trouble. - (inferior-octave-send-list-and-digest (list "PS2\n")) - (if (string-match "\\(PS2\\|ans\\) = *$" (car inferior-octave-output-list)) - (inferior-octave-send-list-and-digest - (list (if inferior-octave-has-built-in-variables - "PS2 = \"> \"\n" - "PS2 (\"> \");\n")))) - - ;; O.k., now we are ready for the Inferior Octave startup commands. - (let* (commands - (program (file-name-nondirectory inferior-octave-program)) - (file (or inferior-octave-startup-file - (concat "~/.emacs-" program)))) - (setq commands - (list "more off;\n" - (if (not (string-equal - inferior-octave-output-string ">> ")) - (if inferior-octave-has-built-in-variables - "PS1=\"\\\\s> \";\n" - "PS1 (\"\\\\s> \");\n")) - (if (file-exists-p file) - (format "source (\"%s\");\n" file)))) - (inferior-octave-send-list-and-digest commands)) - (insert-before-markers - (concat - (if inferior-octave-output-list - (concat (mapconcat - 'identity inferior-octave-output-list "\n") - "\n")) - inferior-octave-output-string)) - ;; Next, we check whether Octave supports `completion_matches' ... - (inferior-octave-send-list-and-digest - (list "exist \"completion_matches\"\n")) - (setq inferior-octave-complete-impossible - (not (string-match "5$" (car inferior-octave-output-list)))) - - ;; 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))) - - -(defun inferior-octave-completion-at-point () - "Return the data to complete the Octave symbol at point." - (let* ((end (point)) - (start - (save-excursion - (skip-syntax-backward "w_" (comint-line-beginning-position)) - (point)))) - (cond ((eq start end) nil) - (inferior-octave-complete-impossible - (message (concat - "Your Octave does not have `completion_matches'. " - "Please upgrade to version 2.X.")) - nil) - (t - (list - start end - (completion-table-dynamic - (lambda (command) - (inferior-octave-send-list-and-digest - (list (concat "completion_matches (\"" command "\");\n"))) - (sort (delete-dups inferior-octave-output-list) - 'string-lessp)))))))) - -(define-obsolete-function-alias 'inferior-octave-complete - 'completion-at-point "24.1") - -(defun inferior-octave-dynamic-list-input-ring () - "List the buffer's input history in a help buffer." - ;; We cannot use `comint-dynamic-list-input-ring', because it replaces - ;; "completion" by "history reference" ... - (interactive) - (if (or (not (ring-p comint-input-ring)) - (ring-empty-p comint-input-ring)) - (message "No history") - (let ((history nil) - (history-buffer " *Input History*") - (index (1- (ring-length comint-input-ring))) - (conf (current-window-configuration))) - ;; We have to build up a list ourselves from the ring vector. - (while (>= index 0) - (setq history (cons (ring-ref comint-input-ring index) history) - index (1- index))) - ;; Change "completion" to "history reference" - ;; to make the display accurate. - (with-output-to-temp-buffer history-buffer - (display-completion-list history) - (set-buffer history-buffer)) - (message "Hit space to flush") - (let ((ch (read-event))) - (if (eq ch ?\ ) - (set-window-configuration conf) - (setq unread-command-events (list ch))))))) - -(defun inferior-octave-strip-ctrl-g (string) - "Strip leading `^G' character. -If STRING starts with a `^G', ring the bell and strip it." - (if (string-match "^\a" string) - (progn - (ding) - (setq string (substring string 1)))) - string) - -(defun inferior-octave-output-filter (proc string) - "Standard output filter for the inferior Octave process. -Ring Emacs bell if process output starts with an ASCII bell, and pass -the rest to `comint-output-filter'." - (comint-output-filter proc (inferior-octave-strip-ctrl-g string))) - -(defun inferior-octave-output-digest (_proc string) - "Special output filter for the inferior Octave process. -Save all output between newlines into `inferior-octave-output-list', and -the rest to `inferior-octave-output-string'." - (setq string (concat inferior-octave-output-string string)) - (while (string-match "\n" string) - (setq inferior-octave-output-list - (append inferior-octave-output-list - (list (substring string 0 (match-beginning 0)))) - string (substring string (match-end 0)))) - (if (string-match inferior-octave-prompt string) - (setq inferior-octave-receive-in-progress nil)) - (setq inferior-octave-output-string string)) - -(defun inferior-octave-send-list-and-digest (list) - "Send LIST to the inferior Octave process and digest the output. -The elements of LIST have to be strings and are sent one by one. All -output is passed to the filter `inferior-octave-output-digest'." - (let* ((proc inferior-octave-process) - string) - (add-function :override (process-filter proc) - #'inferior-octave-output-digest) - (setq inferior-octave-output-list nil) - (unwind-protect - (while (setq string (car list)) - (setq inferior-octave-output-string nil - inferior-octave-receive-in-progress t) - (comint-send-string proc string) - (while inferior-octave-receive-in-progress - (accept-process-output proc)) - (setq list (cdr list))) - (remove-function (process-filter proc) - #'inferior-octave-output-digest)))) - -(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." - (cond - ((string-match "^[ \t]*cd[ \t;]*$" string) - (cd "~")) - ((string-match "^[ \t]*cd[ \t]+\\([^ \t\n;]*\\)[ \t\n;]*" string) - (cd (substring string (match-beginning 1) (match-end 1)))))) - -(defun inferior-octave-resync-dirs () - "Resync the buffer's idea of the current directory. -This command queries the inferior Octave process about its current -directory and makes this the current buffer's default directory." - (interactive) - (inferior-octave-send-list-and-digest '("disp (pwd ())\n")) - (cd (car inferior-octave-output-list))) - -;;; provide ourself - -(provide 'octave-inf) - -;;; octave-inf.el ends here === renamed file 'lisp/progmodes/octave-mod.el' => 'lisp/progmodes/octave.el' --- lisp/progmodes/octave-mod.el 2013-04-25 03:25:34 +0000 +++ lisp/progmodes/octave.el 2013-04-25 14:51:08 +0000 @@ -1,4 +1,4 @@ -;;; octave-mod.el --- editing Octave source files under Emacs +;;; octave.el --- editing octave source files under emacs ;; Copyright (C) 1997, 2001-2013 Free Software Foundation, Inc. @@ -24,30 +24,21 @@ ;;; Commentary: -;; This package provides Emacs support for Octave. -;; It defines Octave mode, a major mode for editing -;; Octave code. - -;; The file octave-inf.el contains code for interacting with an inferior -;; Octave process using comint. - -;; See the documentation of `octave-mode' and -;; `run-octave' for further information on usage and customization. +;; This package provides emacs support for octave. It defines a major +;; mode for editing octave code and contains code for interacting with +;; an inferior octave process using comint. + +;; See the documentation of `octave-mode' and `run-octave' for further +;; information on usage and customization. ;;; Code: -(require 'custom) +(require 'comint) (defgroup octave nil - "Major mode for editing Octave source files." + "Editing Octave code." :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) :group 'languages) -(defvar inferior-octave-output-list nil) -(defvar inferior-octave-output-string nil) -(defvar inferior-octave-receive-in-progress nil) - -(declare-function inferior-octave-send-list-and-digest "octave-inf" (list)) - (defconst octave-maintainer-address "Kurt Hornik , bug-gnu-emacs@gnu.org" "Current maintainer of the Emacs Octave package.") @@ -84,7 +75,7 @@ ("`upc" "unwind_protect_cleanup") ("`w" "while ()"))) "Abbrev table for Octave's reserved words. -Used in `octave-mode' and inferior-octave-mode buffers. +Used in `octave-mode' and `inferior-octave-mode' buffers. All Octave abbrevs start with a grave accent (`)." :regexp "\\(?:[^`]\\|^\\)\\(\\(?:\\<\\|`\\)\\w+\\)\\W*") @@ -156,6 +147,7 @@ The string `function' and its name are given by the first and third parenthetical grouping.") + (defvar octave-font-lock-keywords (list ;; Fontify all builtin keywords. @@ -201,12 +193,6 @@ (put-text-property (match-beginning 1) (match-end 1) 'syntax-table (string-to-syntax "\"'"))))) -(defcustom inferior-octave-buffer "*Inferior Octave*" - "Name of buffer for running an inferior Octave process." - :type 'string - :group 'octave-inferior) - -(defvar inferior-octave-process nil) (defvar octave-mode-map (let ((map (make-sparse-keymap))) @@ -655,6 +641,357 @@ (easy-menu-add octave-mode-menu) (octave-initialize-completions)) + + +(defcustom inferior-octave-program "octave" + "Program invoked by `inferior-octave'." + :type 'string + :group 'octave) + +(defcustom inferior-octave-buffer "*Inferior Octave*" + "Name of buffer for running an inferior Octave process." + :type 'string + :group 'octave) + +(defcustom inferior-octave-prompt + "\\(^octave\\(\\|.bin\\|.exe\\)\\(-[.0-9]+\\)?\\(:[0-9]+\\)?\\|^debug\\|^\\)>+ " + "Regexp to match prompts for the inferior Octave process." + :type 'regexp + :group 'octave) + +(defcustom inferior-octave-startup-file nil + "Name of the inferior Octave startup file. +The contents of this file are sent to the inferior Octave process on +startup." + :type '(choice (const :tag "None" nil) + file) + :group 'octave) + +(defcustom inferior-octave-startup-args nil + "List of command line arguments for the inferior Octave process. +For example, for suppressing the startup message and using `traditional' +mode, set this to (\"-q\" \"--traditional\")." + :type '(repeat string) + :group 'octave) + +(defcustom inferior-octave-mode-hook nil + "Hook to be run when Inferior Octave mode is started." + :type 'hook + :group 'octave) + +(defvar inferior-octave-process nil) + +(defvar inferior-octave-mode-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map comint-mode-map) + (define-key map "\t" 'comint-dynamic-complete) + (define-key map "\M-?" 'comint-dynamic-list-filename-completions) + (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring) + (define-key map [menu-bar inout list-history] + '("List Input History" . inferior-octave-dynamic-list-input-ring)) + map) + "Keymap used in Inferior Octave mode.") + +(defvar inferior-octave-mode-syntax-table + (let ((table (make-syntax-table octave-mode-syntax-table))) + table) + "Syntax table in use in inferior-octave-mode buffers.") + +(defvar inferior-octave-font-lock-keywords + (list + (cons inferior-octave-prompt 'font-lock-type-face)) + ;; Could certainly do more font locking in inferior Octave ... + "Additional expressions to highlight in Inferior Octave mode.") + + +;;; Compatibility functions +(if (not (fboundp 'comint-line-beginning-position)) + ;; comint-line-beginning-position is defined in Emacs 21 + (defun comint-line-beginning-position () + "Returns the buffer position of the beginning of the line, after any prompt. +The prompt is assumed to be any text at the beginning of the line matching +the regular expression `comint-prompt-regexp', a buffer local variable." + (save-excursion (comint-bol nil) (point)))) + + +(defvar inferior-octave-output-list nil) +(defvar inferior-octave-output-string nil) +(defvar inferior-octave-receive-in-progress nil) + +(defvar inferior-octave-startup-hook nil) + +(defvar inferior-octave-complete-impossible nil + "Non-nil means that `inferior-octave-complete' is impossible.") + +(defvar inferior-octave-has-built-in-variables nil + "Non-nil means that Octave has built-in variables.") + +(defvar inferior-octave-dynamic-complete-functions + '(inferior-octave-completion-at-point comint-filename-completion) + "List of functions called to perform completion for inferior Octave. +This variable is used to initialize `comint-dynamic-complete-functions' +in the Inferior Octave buffer.") + +(defvar info-lookup-mode) + +(define-derived-mode inferior-octave-mode comint-mode "Inferior Octave" + "Major mode for interacting with an inferior Octave process. +Runs Octave as a subprocess of Emacs, with Octave I/O through an Emacs +buffer. + +Entry to this mode successively runs the hooks `comint-mode-hook' and +`inferior-octave-mode-hook'." + (setq comint-prompt-regexp inferior-octave-prompt + mode-line-process '(":%s") + local-abbrev-table octave-abbrev-table) + + (set (make-local-variable 'comment-start) octave-comment-start) + (set (make-local-variable 'comment-end) "") + (set (make-local-variable 'comment-column) 32) + (set (make-local-variable 'comment-start-skip) octave-comment-start-skip) + + (set (make-local-variable 'font-lock-defaults) + '(inferior-octave-font-lock-keywords nil nil)) + + (set (make-local-variable 'info-lookup-mode) 'octave-mode) + + (setq comint-input-ring-file-name + (or (getenv "OCTAVE_HISTFILE") "~/.octave_hist") + comint-input-ring-size (or (getenv "OCTAVE_HISTSIZE") 1024)) + (set (make-local-variable 'comint-dynamic-complete-functions) + inferior-octave-dynamic-complete-functions) + (add-hook 'comint-input-filter-functions + 'inferior-octave-directory-tracker nil t) + (comint-read-input-ring t)) + +;;;###autoload +(defun inferior-octave (&optional arg) + "Run an inferior Octave process, I/O via `inferior-octave-buffer'. +This buffer is put in Inferior Octave mode. See `inferior-octave-mode'. + +Unless ARG is non-nil, switches to this buffer. + +The elements of the list `inferior-octave-startup-args' are sent as +command line arguments to the inferior Octave process on startup. + +Additional commands to be executed on startup can be provided either in +the file specified by `inferior-octave-startup-file' or by the default +startup file, `~/.emacs-octave'." + (interactive "P") + (let ((buffer inferior-octave-buffer)) + (get-buffer-create buffer) + (if (comint-check-proc buffer) + () + (with-current-buffer buffer + (comint-mode) + (inferior-octave-startup) + (inferior-octave-mode))) + (if (not arg) + (pop-to-buffer buffer)))) + +;;;###autoload +(defalias 'run-octave 'inferior-octave) + +(defun inferior-octave-startup () + "Start an inferior Octave process." + (let ((proc (comint-exec-1 + (substring inferior-octave-buffer 1 -1) + inferior-octave-buffer + inferior-octave-program + (append (list "-i" "--no-line-editing") + inferior-octave-startup-args)))) + (set-process-filter proc 'inferior-octave-output-digest) + (setq comint-ptyp process-connection-type + inferior-octave-process proc + inferior-octave-output-list nil + inferior-octave-output-string nil + inferior-octave-receive-in-progress t) + + ;; This may look complicated ... However, we need to make sure that + ;; we additional startup code only AFTER Octave is ready (otherwise, + ;; output may be mixed up). Hence, we need to digest the Octave + ;; output to see when it issues a prompt. + (while inferior-octave-receive-in-progress + (accept-process-output inferior-octave-process)) + (goto-char (point-max)) + (set-marker (process-mark proc) (point)) + (insert-before-markers + (concat + (if (not (bobp)) " \n") + (if inferior-octave-output-list + (concat (mapconcat + 'identity inferior-octave-output-list "\n") + "\n")))) + + ;; Find out whether Octave has built-in variables. + (inferior-octave-send-list-and-digest + (list "exist \"LOADPATH\"\n")) + (setq inferior-octave-has-built-in-variables + (string-match "101$" (car inferior-octave-output-list))) + + ;; An empty secondary prompt, as e.g. obtained by '--braindead', + ;; means trouble. + (inferior-octave-send-list-and-digest (list "PS2\n")) + (if (string-match "\\(PS2\\|ans\\) = *$" (car inferior-octave-output-list)) + (inferior-octave-send-list-and-digest + (list (if inferior-octave-has-built-in-variables + "PS2 = \"> \"\n" + "PS2 (\"> \");\n")))) + + ;; O.k., now we are ready for the Inferior Octave startup commands. + (let* (commands + (program (file-name-nondirectory inferior-octave-program)) + (file (or inferior-octave-startup-file + (concat "~/.emacs-" program)))) + (setq commands + (list "more off;\n" + (if (not (string-equal + inferior-octave-output-string ">> ")) + (if inferior-octave-has-built-in-variables + "PS1=\"\\\\s> \";\n" + "PS1 (\"\\\\s> \");\n")) + (if (file-exists-p file) + (format "source (\"%s\");\n" file)))) + (inferior-octave-send-list-and-digest commands)) + (insert-before-markers + (concat + (if inferior-octave-output-list + (concat (mapconcat + 'identity inferior-octave-output-list "\n") + "\n")) + inferior-octave-output-string)) + ;; Next, we check whether Octave supports `completion_matches' ... + (inferior-octave-send-list-and-digest + (list "exist \"completion_matches\"\n")) + (setq inferior-octave-complete-impossible + (not (string-match "5$" (car inferior-octave-output-list)))) + + ;; 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))) + +(defun inferior-octave-completion-at-point () + "Return the data to complete the Octave symbol at point." + (let* ((end (point)) + (start + (save-excursion + (skip-syntax-backward "w_" (comint-line-beginning-position)) + (point)))) + (cond ((eq start end) nil) + (inferior-octave-complete-impossible + (message (concat + "Your Octave does not have `completion_matches'. " + "Please upgrade to version 2.X.")) + nil) + (t + (list + start end + (completion-table-dynamic + (lambda (command) + (inferior-octave-send-list-and-digest + (list (concat "completion_matches (\"" command "\");\n"))) + (sort (delete-dups inferior-octave-output-list) + 'string-lessp)))))))) + +(define-obsolete-function-alias 'inferior-octave-complete + 'completion-at-point "24.1") + +(defun inferior-octave-dynamic-list-input-ring () + "List the buffer's input history in a help buffer." + ;; We cannot use `comint-dynamic-list-input-ring', because it replaces + ;; "completion" by "history reference" ... + (interactive) + (if (or (not (ring-p comint-input-ring)) + (ring-empty-p comint-input-ring)) + (message "No history") + (let ((history nil) + (history-buffer " *Input History*") + (index (1- (ring-length comint-input-ring))) + (conf (current-window-configuration))) + ;; We have to build up a list ourselves from the ring vector. + (while (>= index 0) + (setq history (cons (ring-ref comint-input-ring index) history) + index (1- index))) + ;; Change "completion" to "history reference" + ;; to make the display accurate. + (with-output-to-temp-buffer history-buffer + (display-completion-list history) + (set-buffer history-buffer)) + (message "Hit space to flush") + (let ((ch (read-event))) + (if (eq ch ?\ ) + (set-window-configuration conf) + (setq unread-command-events (list ch))))))) + +(defun inferior-octave-strip-ctrl-g (string) + "Strip leading `^G' character. +If STRING starts with a `^G', ring the bell and strip it." + (if (string-match "^\a" string) + (progn + (ding) + (setq string (substring string 1)))) + string) + +(defun inferior-octave-output-filter (proc string) + "Standard output filter for the inferior Octave process. +Ring Emacs bell if process output starts with an ASCII bell, and pass +the rest to `comint-output-filter'." + (comint-output-filter proc (inferior-octave-strip-ctrl-g string))) + +(defun inferior-octave-output-digest (_proc string) + "Special output filter for the inferior Octave process. +Save all output between newlines into `inferior-octave-output-list', and +the rest to `inferior-octave-output-string'." + (setq string (concat inferior-octave-output-string string)) + (while (string-match "\n" string) + (setq inferior-octave-output-list + (append inferior-octave-output-list + (list (substring string 0 (match-beginning 0)))) + string (substring string (match-end 0)))) + (if (string-match inferior-octave-prompt string) + (setq inferior-octave-receive-in-progress nil)) + (setq inferior-octave-output-string string)) + +(defun inferior-octave-send-list-and-digest (list) + "Send LIST to the inferior Octave process and digest the output. +The elements of LIST have to be strings and are sent one by one. All +output is passed to the filter `inferior-octave-output-digest'." + (let* ((proc inferior-octave-process) + (filter (process-filter proc)) + string) + (set-process-filter proc 'inferior-octave-output-digest) + (setq inferior-octave-output-list nil) + (unwind-protect + (while (setq string (car list)) + (setq inferior-octave-output-string nil + inferior-octave-receive-in-progress t) + (comint-send-string proc string) + (while inferior-octave-receive-in-progress + (accept-process-output proc)) + (setq list (cdr list))) + (set-process-filter proc filter)))) + +(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." + (cond + ((string-match "^[ \t]*cd[ \t;]*$" string) + (cd "~")) + ((string-match "^[ \t]*cd[ \t]+\\([^ \t\n;]*\\)[ \t\n;]*" string) + (cd (substring string (match-beginning 1) (match-end 1)))))) + +(defun inferior-octave-resync-dirs () + "Resync the buffer's idea of the current directory. +This command queries the inferior Octave process about its current +directory and makes this the current buffer's default directory." + (interactive) + (inferior-octave-send-list-and-digest '("disp (pwd ())\n")) + (cd (car inferior-octave-output-list))) + ;;; Miscellaneous useful functions @@ -1143,8 +1480,5 @@ 'octave-send-line-auto-forward 'octave-send-show-buffer)))) -;; provide ourself - -(provide 'octave-mod) - -;;; octave-mod.el ends here +(provide 'octave) +;;; octave.el ends here ------------------------------------------------------------ revno: 112380 committer: Tassilo Horn branch nick: trunk timestamp: Thu 2013-04-25 14:01:09 +0200 message: * textmodes/reftex-vars.el (reftex-label-ignored-macros-and-environments): New defcustom. * textmodes/reftex-parse.el (reftex-parse-from-file): Use it. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-04-25 03:25:34 +0000 +++ lisp/ChangeLog 2013-04-25 12:01:09 +0000 @@ -1,3 +1,10 @@ +2013-04-25 Tassilo Horn + + * textmodes/reftex-vars.el + (reftex-label-ignored-macros-and-environments): New defcustom. + + * textmodes/reftex-parse.el (reftex-parse-from-file): Use it. + 2013-04-25 Stefan Monnier * emacs-lisp/smie.el (smie-indent--hanging-p): Don't burp at EOB. === modified file 'lisp/textmodes/reftex-parse.el' --- lisp/textmodes/reftex-parse.el 2013-01-02 16:13:04 +0000 +++ lisp/textmodes/reftex-parse.el 2013-04-25 12:01:09 +0000 @@ -234,8 +234,18 @@ ((match-end 1) ;; It is a label - (push (reftex-label-info (reftex-match-string 1) file bound) - docstruct)) + (when (or (null reftex-label-ignored-macros-and-environments) + ;; \label{} defs should always be honored, + ;; just no keyval style [label=foo] defs. + (string-equal "\label{" (substring (reftex-match-string 0) 0 7)) + (not (fboundp 'TeX-current-macro)) + (not (fboundp 'LaTeX-current-environment)) + (not (or (member (save-match-data (TeX-current-macro)) + reftex-label-ignored-macros-and-environments) + (member (save-match-data (LaTeX-current-environment)) + reftex-label-ignored-macros-and-environments)))) + (push (reftex-label-info (reftex-match-string 1) file bound) + docstruct))) ((match-end 3) ;; It is a section === modified file 'lisp/textmodes/reftex-vars.el' --- lisp/textmodes/reftex-vars.el 2013-04-23 17:07:49 +0000 +++ lisp/textmodes/reftex-vars.el 2013-04-25 12:01:09 +0000 @@ -885,6 +885,25 @@ :group 'reftex-defining-label-environments :type '(repeat (regexp :tag "Regular Expression"))) +(defcustom reftex-label-ignored-macros-and-environments nil + "List of macros and environments to be ignored when searching for labels. +The purpose is to ignore environments and macros that use keyval +style label=foo arguments, but the label has a different meaning +than a \\label{foo}. Standard \\label{...} definitions are never +ignored. + +E.g., TikZ defines several macros/environments where [label=foo] +defines the label to be printed at some node or edge, but it's +not a label used for referencing. + +Note that this feature is only supported if you are using AUCTeX +and the functions `TeX-current-macro' and +`LaTeX-current-environment' are bound. Also note that this +feature might slow down the reftex parsing process for large TeX +files." + :group 'reftex-defining-label-environments + :type '(repeat string)) + (defcustom reftex-label-illegal-re "[^-a-zA-Z0-9_+=:;,.]" "Regexp matching characters not valid in labels." :group 'reftex-making-and-inserting-labels ------------------------------------------------------------ revno: 112379 fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14218 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2013-04-24 23:25:34 -0400 message: * lisp/progmodes/octave-mod.el (octave-smie-forward-token): Only emit semi-colons if the line is not otherwise empty. * lisp/emacs-lisp/smie.el (smie-indent--hanging-p): Don't burp at EOB. (smie-indent-keyword): Improve the check to ensure that the next comment is really on the same line. (smie-indent-comment): Don't align with a subsequent closer (or eob). diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-04-25 00:53:18 +0000 +++ lisp/ChangeLog 2013-04-25 03:25:34 +0000 @@ -1,3 +1,13 @@ +2013-04-25 Stefan Monnier + + * emacs-lisp/smie.el (smie-indent--hanging-p): Don't burp at EOB. + (smie-indent-keyword): Improve the check to ensure that the next + comment is really on the same line. + (smie-indent-comment): Don't align with a subsequent closer (or eob). + + * progmodes/octave-mod.el (octave-smie-forward-token): Only emit + semi-colons if the line is not otherwise empty (bug#14218). + 2013-04-25 Glenn Morris * vc/vc-bzr.el (vc-bzr-print-log): Tweak LIMIT = 1 case. === modified file 'lisp/emacs-lisp/smie.el' --- lisp/emacs-lisp/smie.el 2013-03-14 14:48:03 +0000 +++ lisp/emacs-lisp/smie.el 2013-04-25 03:25:34 +0000 @@ -1067,9 +1067,10 @@ (save-excursion (<= (line-end-position) (progn - (when (zerop (length (funcall smie-forward-token-function))) - ;; Could be an open-paren. - (forward-char 1)) + (and (zerop (length (funcall smie-forward-token-function))) + (not (eobp)) + ;; Could be an open-paren. + (forward-char 1)) (skip-chars-forward " \t") (or (eolp) (and (looking-at comment-start-skip) @@ -1350,8 +1351,11 @@ (if (and (< pos (line-beginning-position)) ;; Make sure `token' also *starts* on another line. (save-excursion - (smie-indent-backward-token) - (< pos (line-beginning-position)))) + (let ((endpos (point))) + (goto-char pos) + (forward-line 1) + (and (equal res (smie-indent-forward-token)) + (eq (point) endpos))))) nil (goto-char pos) res))))) @@ -1473,13 +1477,21 @@ (save-excursion (forward-comment (point-max)) (skip-chars-forward " \t\r\n") - ;; FIXME: We assume here that smie-indent-calculate will compute the - ;; indentation of the next token based on text before the comment, but - ;; this is not guaranteed, so maybe we should let - ;; smie-indent-calculate return some info about which buffer position - ;; was used as the "indentation base" and check that this base is - ;; before `pos'. - (smie-indent-calculate)))) + (unless + ;; Don't align with a closer, since the comment is "within" the + ;; closed element. Don't align with EOB either. + (save-excursion + (let ((next (funcall smie-forward-token-function))) + (or (if (zerop (length next)) + (or (eobp) (eq (car (syntax-after (point))) 5))) + (rassoc next smie-closer-alist)))) + ;; FIXME: We assume here that smie-indent-calculate will compute the + ;; indentation of the next token based on text before the comment, + ;; but this is not guaranteed, so maybe we should let + ;; smie-indent-calculate return some info about which buffer + ;; position was used as the "indentation base" and check that this + ;; base is before `pos'. + (smie-indent-calculate))))) (defun smie-indent-comment-continue () ;; indentation of comment-continue lines. === modified file 'lisp/progmodes/octave-mod.el' --- lisp/progmodes/octave-mod.el 2013-04-17 01:49:22 +0000 +++ lisp/progmodes/octave-mod.el 2013-04-25 03:25:34 +0000 @@ -482,6 +482,7 @@ (forward-comment 1)) (cond ((and (looking-at "$\\|[%#]") + (not (smie-rule-bolp)) ;; Ignore it if it's within parentheses. (prog1 (let ((ppss (syntax-ppss))) (not (and (nth 1 ppss)