diff options
| author | Jan D <jan.h.d@swipnet.se> | 2015-04-26 13:55:01 +0200 |
|---|---|---|
| committer | Jan D <jan.h.d@swipnet.se> | 2015-04-26 13:55:01 +0200 |
| commit | f92ac2e82ed199d6f25d2a59508e08addb1150ac (patch) | |
| tree | d7d7756e3dbce10d8f73c27815d815499f78c2bd /lisp/textmodes | |
| parent | 5a094119ce79723108abd90a1fcc33721e964823 (diff) | |
| parent | a40869789fc5502e3d4e393b7c31d78cb7f29aa1 (diff) | |
| download | emacs-f92ac2e82ed199d6f25d2a59508e08addb1150ac.tar.gz | |
Merge branch 'master' into cairo
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/bibtex.el | 2 | ||||
| -rw-r--r-- | lisp/textmodes/css-mode.el | 29 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-cite.el | 12 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-index.el | 29 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-ref.el | 3 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-toc.el | 19 | ||||
| -rw-r--r-- | lisp/textmodes/reftex.el | 8 | ||||
| -rw-r--r-- | lisp/textmodes/sgml-mode.el | 127 | ||||
| -rw-r--r-- | lisp/textmodes/table.el | 53 | ||||
| -rw-r--r-- | lisp/textmodes/tex-mode.el | 10 | ||||
| -rw-r--r-- | lisp/textmodes/text-mode.el | 6 |
11 files changed, 169 insertions, 129 deletions
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index 5933559b37c..8a018520f5f 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -2229,7 +2229,7 @@ Optional arg COMMA is as in `bibtex-enclosing-field'." bibtex-entry-kill-ring)) ;; If we copied an entry from a buffer containing only this one entry, ;; it can be missing the second "\n". - (unless (looking-back "\n\n") (insert "\n")) + (unless (looking-back "\n\n" (- (point 2))) (insert "\n")) (unless (functionp bibtex-reference-keys) ;; update `bibtex-reference-keys' (save-excursion diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 72800808e65..424cdb7f830 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -41,7 +41,7 @@ (defconst css-pseudo-class-ids '("active" "checked" "disabled" "empty" "enabled" "first" "first-child" "first-of-type" "focus" "hover" "indeterminate" "lang" - "last-child" "last-of-type" "left" "link" "nth-child" + "last-child" "last-of-type" "left" "link" "not" "nth-child" "nth-last-child" "nth-last-of-type" "nth-of-type" "only-child" "only-of-type" "right" "root" "target" "visited") "Identifiers for pseudo-classes.") @@ -327,6 +327,10 @@ (`(:elem . basic) css-indent-offset) (`(:elem . arg) 0) (`(:list-intro . ,(or `";" `"")) t) ;"" stands for BOB (bug#15467). + (`(:before . "{") + (when (smie-rule-hanging-p) + (smie-backward-sexp ";") + (smie-indent-virtual))) (`(:before . ,(or "{" "(")) (if (smie-rule-hanging-p) (smie-rule-parent 0))))) @@ -377,7 +381,8 @@ pseudo-classes, and at-rules." (setq-local comment-start-skip "/\\*+[ \t]*") (setq-local comment-end "*/") (setq-local comment-end-skip "[ \t]*\\*+/") - (setq-local fill-paragraph-function 'css-fill-paragraph) + (setq-local fill-paragraph-function #'css-fill-paragraph) + (setq-local adaptive-fill-function #'css-adaptive-fill) (setq-local add-log-current-defun-function #'css-current-defun-name) (smie-setup css-smie-grammar #'css-smie-rules :forward-token #'css-smie--forward-token @@ -391,6 +396,12 @@ pseudo-classes, and at-rules." (defun css-fill-paragraph (&optional justify) (save-excursion + ;; Fill succeeding comment when invoked right before a multi-line + ;; comment. + (when (save-excursion + (beginning-of-line) + (comment-search-forward (point-at-eol) t)) + (goto-char (match-end 0))) (let ((ppss (syntax-ppss)) (eol (line-end-position))) (cond @@ -410,8 +421,11 @@ pseudo-classes, and at-rules." (paragraph-separate (if (and comment-continue (string-match "[^ \t]" comment-continue)) - (concat "\\(?:[ \t]*" (regexp-quote comment-continue) - "\\)?\\(?:" paragraph-separate "\\)") + (concat "\\(?:[ \t]*\\(?:" + (regexp-quote comment-continue) "\\|" + comment-start-skip "\\|" + comment-end-skip "\\)\\)?" + "\\(?:" paragraph-separate "\\)") paragraph-separate)) (paragraph-start (if (and comment-continue @@ -464,6 +478,12 @@ pseudo-classes, and at-rules." ;; Don't use the default filling code. t))))))) +(defun css-adaptive-fill () + (when (looking-at "[ \t]*/\\*[ \t]*") + (let ((str (match-string 0))) + (and (string-match "/\\*" str) + (replace-match " *" t t str))))) + (defun css-current-defun-name () "Return the name of the CSS section at point, or nil." (save-excursion @@ -500,6 +520,7 @@ pseudo-classes, and at-rules." "Major mode to edit \"Sassy CSS\" files." (setq-local comment-start "// ") (setq-local comment-end "") + (setq-local comment-continue " *") (setq-local comment-start-skip "/[*/]+[ \t]*") (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)") (setq-local font-lock-defaults '(scss-font-lock-keywords nil t))) diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el index fa09efb64a4..b22e8b1dcc0 100644 --- a/lisp/textmodes/reftex-cite.el +++ b/lisp/textmodes/reftex-cite.el @@ -197,7 +197,7 @@ Return list with entries." "[" default "]: ") (if reftex-mode (if (fboundp 'LaTeX-bibitem-list) - (LaTeX-bibitem-list) + (or (LaTeX-bibitem-list) '("")) (cdr (assoc 'bibview-cache (symbol-value reftex-docstruct-symbol)))) nil) @@ -228,11 +228,11 @@ Return list with entries." (message "No such BibTeX file %s (ignored)" buffer) (message "Scanning bibliography database %s" buffer1) (unless (verify-visited-file-modtime buffer1) - (when (y-or-n-p - (format "File %s changed on disk. Reread from disk? " - (file-name-nondirectory - (buffer-file-name buffer1)))) - (with-current-buffer buffer1 (revert-buffer t t))))) + (when (y-or-n-p + (format "File %s changed on disk. Reread from disk? " + (file-name-nondirectory + (buffer-file-name buffer1)))) + (with-current-buffer buffer1 (revert-buffer t t))))) (set-buffer buffer1) (reftex-with-special-syntax-for-bib diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el index b1aff428278..7e961e83406 100644 --- a/lisp/textmodes/reftex-index.el +++ b/lisp/textmodes/reftex-index.el @@ -544,18 +544,28 @@ With prefix 3, restrict index to region." (setq buffer-read-only nil) (insert (format -"INDEX <%s> on %s + "INDEX <%s> on %s Restriction: <%s> SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan [f]ollow [?]Help ------------------------------------------------------------------------------ -" index-tag (abbreviate-file-name master) -(if (eq (car (car reftex-index-restriction-data)) 'toc) - (nth 2 (car reftex-index-restriction-data)) - reftex-index-restriction-indicator))) +" + index-tag (abbreviate-file-name master) + (if (eq (car (car reftex-index-restriction-data)) 'toc) + (nth 2 (car reftex-index-restriction-data)) + reftex-index-restriction-indicator))) (if (reftex-use-fonts) - (put-text-property 1 (point) 'face reftex-index-header-face)) - (put-text-property 1 (point) 'intangible t) + (put-text-property (point-min) (point) + 'face reftex-index-header-face)) + (if (fboundp 'cursor-intangible-mode) + (cursor-intangible-mode 1) + ;; If `cursor-intangible' is not available, fallback on the old + ;; intrusive `intangible' property. + (put-text-property (point-min) (point) 'intangible t)) + (add-text-properties (point-min) (point) + '(cursor-intangible t + front-sticky (cursor-intangible) + rear-nonsticky (cursor-intangible))) (reftex-insert-index docstruct index-tag) (goto-char (point-min)) @@ -697,9 +707,10 @@ SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan [f]ollow [?]Help (defun reftex-index-post-command-hook () ;; Used in the post-command-hook for the *Index* buffer + ;; FIXME: Lots of redundancy with reftex-toc-post-command-hook! (when (get-text-property (point) :data) - (and (> (point) 1) - (not (get-text-property (point) 'intangible)) + (and (> (point) 1) ;FIXME: Is this point-min or do we care about narrowing? + (not (get-text-property (point) 'cursor-intangible)) (memq reftex-highlight-selection '(cursor both)) (reftex-highlight 1 (or (previous-single-property-change (1+ (point)) :data) diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el index be119d9db58..d0e09bff880 100644 --- a/lisp/textmodes/reftex-ref.el +++ b/lisp/textmodes/reftex-ref.el @@ -857,7 +857,8 @@ Optional prefix argument OTHER-WINDOW goes to the label in another window." (docstruct (symbol-value reftex-docstruct-symbol)) ;; If point is inside a \ref{} or \pageref{}, use that as ;; default value. - (default (when (looking-back "\\\\\\(?:page\\)?ref{[-a-zA-Z0-9_*.:]*") + (default (when (looking-back "\\\\\\(?:page\\)?ref{[-a-zA-Z0-9_*.:]*" + (line-beginning-position)) (reftex-this-word "-a-zA-Z0-9_*.:"))) (label (completing-read (if default (format "Label (default %s): " default) diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el index 69cab782315..085f2d7bdf9 100644 --- a/lisp/textmodes/reftex-toc.el +++ b/lisp/textmodes/reftex-toc.el @@ -280,7 +280,15 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help (if (reftex-use-fonts) (put-text-property (point-min) (point) 'font-lock-face reftex-toc-header-face)) - (put-text-property (point-min) (point) 'intangible t) + (if (fboundp 'cursor-intangible-mode) + (cursor-intangible-mode 1) + ;; If `cursor-intangible' is not available, fallback on the old + ;; intrusive `intangible' property. + (put-text-property (point-min) (point) 'intangible t)) + (add-text-properties (point-min) (point) + '(cursor-intangible t + front-sticky (cursor-intangible) + rear-nonsticky (cursor-intangible))) (put-text-property (point-min) (1+ (point-min)) 'xr-alist xr-alist) (setq offset @@ -331,8 +339,8 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help (let ((current-prefix-arg nil)) (select-window (get-buffer-window buf frame)) (reftex-toc nil t))) - (and (> (point) 1) - (not (get-text-property (point) 'intangible)) + (and (> (point) 1) ;FIXME: Is this point-min or do we care about narrowing? + (not (get-text-property (point) 'cursor-intangible)) (memq reftex-highlight-selection '(cursor both)) (reftex-highlight 2 (or (previous-single-property-change @@ -349,10 +357,11 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help (defun reftex-toc-post-command-hook () ;; used in the post-command-hook for the *toc* buffer + ;; FIXME: Lots of redundancy with reftex-index-post-command-hook! (when (get-text-property (point) :data) (put 'reftex-toc :reftex-data (get-text-property (point) :data)) - (and (> (point) 1) - (not (get-text-property (point) 'intangible)) + (and (> (point) 1) ;FIXME: Is this point-min or do we care about narrowing? + (not (get-text-property (point) 'cursor-intangible)) (memq reftex-highlight-selection '(cursor both)) (reftex-highlight 2 (or (previous-single-property-change (1+ (point)) :data) diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index 7cf54c6d28a..ce083c9a9a0 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el @@ -2446,7 +2446,7 @@ of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . LEVEL). See ;;;*** -;;;### (autoloads nil "reftex-cite" "reftex-cite.el" "5a53c260fa01268c04ea2f558add9d7d") +;;;### (autoloads nil "reftex-cite" "reftex-cite.el" "9e0690737924aef6e3836bc2c42a36c9") ;;; Generated autoloads from reftex-cite.el (autoload 'reftex-default-bibliography "reftex-cite" "\ @@ -2676,7 +2676,7 @@ With no argument, this command toggles ;;;*** -;;;### (autoloads nil "reftex-index" "reftex-index.el" "d80e84d499050e32569a454d8db16861") +;;;### (autoloads nil "reftex-index" "reftex-index.el" "29cb6e91c2e06592053e9d543f30f0ea") ;;; Generated autoloads from reftex-index.el (autoload 'reftex-index-selection-or-word "reftex-index" "\ @@ -2932,7 +2932,7 @@ When LEVEL is non-nil, increase section numbers on that level. ;;;*** -;;;### (autoloads nil "reftex-ref" "reftex-ref.el" "64cd7a4eaec426177a8fb3689139d935") +;;;### (autoloads nil "reftex-ref" "reftex-ref.el" "2689a4cea701a9d284e0967c313da989") ;;; Generated autoloads from reftex-ref.el (autoload 'reftex-label-location "reftex-ref" "\ @@ -3046,7 +3046,7 @@ During a selection process, these are the local bindings. ;;;*** -;;;### (autoloads nil "reftex-toc" "reftex-toc.el" "e04344fac7ba4c2043439e130bdd283f") +;;;### (autoloads nil "reftex-toc" "reftex-toc.el" "8b6d6733d445a55206e84fc119909520") ;;; Generated autoloads from reftex-toc.el (autoload 'reftex-toc "reftex-toc" "\ diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 82666478d59..c71ecb4d7a0 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -1,4 +1,4 @@ -;;; sgml-mode.el --- SGML- and HTML-editing modes -*- coding: utf-8 -*- +;;; sgml-mode.el --- SGML- and HTML-editing modes -*- lexical-binding:t -*- ;; Copyright (C) 1992, 1995-1996, 1998, 2001-2015 Free Software ;; Foundation, Inc. @@ -442,7 +442,7 @@ an optional alist of possible values." (comment-style 'plain)) (comment-indent-new-line soft))) -(defun sgml-mode-facemenu-add-face-function (face end) +(defun sgml-mode-facemenu-add-face-function (face _end) (let ((tag-face (cdr (assq face sgml-face-tag-alist)))) (cond (tag-face (setq tag-face (funcall skeleton-transformation-function tag-face)) @@ -844,7 +844,7 @@ Return non-nil if we skipped over matched tags." (defvar sgml-electric-tag-pair-overlays nil) (defvar sgml-electric-tag-pair-timer nil) -(defun sgml-electric-tag-pair-before-change-function (beg end) +(defun sgml-electric-tag-pair-before-change-function (_beg end) (condition-case err (save-excursion (goto-char end) @@ -1012,7 +1012,7 @@ With prefix argument ARG, repeat this ARG times." (or (get 'sgml-tag 'invisible) (setplist 'sgml-tag (append '(invisible t - point-entered sgml-point-entered + cursor-sensor-functions (sgml-cursor-sensor) rear-nonsticky t read-only t) (symbol-plist 'sgml-tag)))) @@ -1020,63 +1020,59 @@ With prefix argument ARG, repeat this ARG times." (defun sgml-tags-invisible (arg) "Toggle visibility of existing tags." (interactive "P") - (let ((modified (buffer-modified-p)) - (inhibit-read-only t) - (inhibit-modification-hooks t) - ;; Avoid spurious the `file-locked' checks. - (buffer-file-name nil) - ;; This is needed in case font lock gets called, - ;; since it moves point and might call sgml-point-entered. - ;; How could it get called? -stef - (inhibit-point-motion-hooks t) + (let ((inhibit-read-only t) string) - (unwind-protect - (save-excursion - (goto-char (point-min)) - (if (setq-local sgml-tags-invisible - (if arg - (>= (prefix-numeric-value arg) 0) - (not sgml-tags-invisible))) - (while (re-search-forward sgml-tag-name-re nil t) - (setq string - (cdr (assq (intern-soft (downcase (match-string 1))) - sgml-display-text))) - (goto-char (match-beginning 0)) - (and (stringp string) - (not (overlays-at (point))) - (let ((ol (make-overlay (point) (match-beginning 1)))) - (overlay-put ol 'before-string string) - (overlay-put ol 'sgml-tag t))) - (put-text-property (point) - (progn (forward-list) (point)) - 'category 'sgml-tag)) - (let ((pos (point-min))) - (while (< (setq pos (next-overlay-change pos)) (point-max)) - (dolist (ol (overlays-at pos)) - (if (overlay-get ol 'sgml-tag) - (delete-overlay ol))))) - (remove-text-properties (point-min) (point-max) '(category nil)))) - (restore-buffer-modified-p modified)) + (with-silent-modifications + (save-excursion + (goto-char (point-min)) + (if (setq-local sgml-tags-invisible + (if arg + (>= (prefix-numeric-value arg) 0) + (not sgml-tags-invisible))) + (while (re-search-forward sgml-tag-name-re nil t) + (setq string + (cdr (assq (intern-soft (downcase (match-string 1))) + sgml-display-text))) + (goto-char (match-beginning 0)) + (and (stringp string) + (not (overlays-at (point))) + (let ((ol (make-overlay (point) (match-beginning 1)))) + (overlay-put ol 'before-string string) + (overlay-put ol 'sgml-tag t))) + (put-text-property (point) + (progn (forward-list) (point)) + 'category 'sgml-tag)) + (let ((pos (point-min))) + (while (< (setq pos (next-overlay-change pos)) (point-max)) + (dolist (ol (overlays-at pos)) + (if (overlay-get ol 'sgml-tag) + (delete-overlay ol))))) + (remove-text-properties (point-min) (point-max) '(category nil))))) + (cursor-sensor-mode (if sgml-tags-invisible 1 -1)) (run-hooks 'sgml-tags-invisible-hook) (message ""))) -(defun sgml-point-entered (x y) - ;; Show preceding or following hidden tag, depending of cursor direction. - (let ((inhibit-point-motion-hooks t)) - (save-excursion - (condition-case nil - (message "Invisible tag: %s" - ;; Strip properties, otherwise, the text is invisible. - (buffer-substring-no-properties - (point) - (if (or (and (> x y) - (not (eq (following-char) ?<))) - (and (< x y) - (eq (preceding-char) ?>))) - (backward-list) - (forward-list)))) - (error nil))))) - +(defun sgml-cursor-sensor (window x dir) + ;; Show preceding or following hidden tag, depending of cursor direction (and + ;; `dir' is not the direction in this sense). + (when (eq dir 'entered) + (ignore-errors + (let* ((y (window-point window)) + (otherend + (save-excursion + (goto-char y) + (cond + ((and (eq (char-before) ?>) + (or (not (eq (char-after) ?<)) + (> x y))) + (backward-sexp)) + ((eq (char-after y) ?<) + (forward-sexp))) + (point)))) + (message "Invisible tag: %s" + ;; Strip properties, otherwise, the text is invisible. + (buffer-substring-no-properties + y otherend)))))) (defun sgml-validate (command) @@ -1158,7 +1154,7 @@ If nil, start from a preceding tag at indentation." ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state))) (t (cons 'text text-start)))))) -(defun sgml-beginning-of-tag (&optional top-level) +(defun sgml-beginning-of-tag (&optional only-immediate) "Skip to beginning of tag and return its name. If this can't be done, return nil." (let ((context (sgml-lexical-context))) @@ -1167,7 +1163,7 @@ If this can't be done, return nil." (goto-char (cdr context)) (when (looking-at sgml-tag-name-re) (match-string-no-properties 1))) - (if top-level nil + (if only-immediate nil (when (not (eq (car context) 'text)) (goto-char (cdr context)) (sgml-beginning-of-tag t)))))) @@ -1581,6 +1577,19 @@ LCON is the lexical context, if any." (skip-chars-forward " \t\n") (< (point) here) (sgml-at-indentation-p)) (current-column)) + ;; ;; If the parsing failed, try to recover. + ;; ((and (null context) (bobp) + ;; (not (eq (char-after here) ?<))) + ;; (goto-char here) + ;; (if (and (looking-at "--[ \t\n]*>") + ;; (re-search-backward "<!--" nil t)) + ;; ;; No wonder parsing failed: we're in a comment. + ;; (sgml-calculate-indent (prog2 (goto-char (match-end 0)) + ;; (sgml-lexical-context) + ;; (goto-char here))) + ;; ;; We have no clue what's going on, let's be honest about it. + ;; nil)) + ;; Otherwise, just follow the rules. (t (goto-char there) (+ (current-column) diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el index 5059300a5c1..edc78e52efa 100644 --- a/lisp/textmodes/table.el +++ b/lisp/textmodes/table.el @@ -770,7 +770,6 @@ the cell contents dynamically." :type 'integer :group 'table) -;;;###autoload (defcustom table-cell-map-hook nil "Normal hooks run when finishing construction of `table-cell-map'. User can modify `table-cell-map' by adding custom functions here." @@ -794,19 +793,16 @@ simply by any key input." :type 'boolean :group 'table) -;;;###autoload (defcustom table-load-hook nil "List of functions to be called after the table is first loaded." :type 'hook :group 'table-hooks) -;;;###autoload (defcustom table-point-entered-cell-hook nil "List of functions to be called after point entered a table cell." :type 'hook :group 'table-hooks) -;;;###autoload (defcustom table-point-left-cell-hook nil "List of functions to be called after point left a table cell." :type 'hook @@ -865,8 +861,6 @@ time.") "Cache point coordinate based from the cell origin.") (defvar table-cell-cache-mark-coordinate nil "Cache mark coordinate based from the cell origin.") -(defvar table-cell-entered-state nil - "Records the state whether currently in a cell or nor.") (defvar table-update-timer nil "Timer id for deferred cell update.") (defvar table-widen-timer nil @@ -1216,14 +1210,14 @@ This is always set to nil at the entry to `table-with-cache-buffer' before execu ;; does not cause a problem in the old implementation. Sigh... (when (featurep 'xemacs) (defun table--tweak-menu-for-xemacs (menu) - (cond - ((listp menu) - (mapcar #'table--tweak-menu-for-xemacs menu)) - ((vectorp menu) - (let ((len (length menu))) - (dotimes (i len) - ;; replace :help with something harmless. - (if (eq (aref menu i) :help) (aset menu i :included))))))) + (cond + ((listp menu) + (mapcar #'table--tweak-menu-for-xemacs menu)) + ((vectorp menu) + (let ((len (length menu))) + (dotimes (i len) + ;; replace :help with something harmless. + (if (eq (aref menu i) :help) (aset menu i :included))))))) (mapcar #'table--tweak-menu-for-xemacs (list table-global-menu table-cell-menu)) (defvar mark-active t)) @@ -5187,8 +5181,8 @@ and the right cell border character." (defun table--put-cell-point-entered/left-property (beg end &optional object) "Put point-entered/left property." - (put-text-property beg end 'point-entered 'table--point-entered-cell-function object) - (put-text-property beg end 'point-left 'table--point-left-cell-function object)) + (put-text-property beg end 'cursor-sensor-functions + '(table--point-entered/left-cell-function) object)) (defun table--remove-cell-properties (beg end &optional object) "Remove all cell properties. @@ -5204,8 +5198,7 @@ instead of the current buffer and returns the OBJECT." 'table-valign nil 'face nil 'rear-nonsticky nil - 'point-entered nil - 'point-left nil + 'cursor-sensor-functions nil 'keymap nil) object)) (setq beg next))) @@ -5247,28 +5240,20 @@ instead of the current buffer and returns the OBJECT." "Put cell's vertical alignment property." (table--put-property cell 'table-valign valign)) -(defun table--point-entered-cell-function (&optional _old-point _new-point) +(defun table--point-entered/left-cell-function (_window _oldpos dir) "Point has entered a cell. Refresh the menu bar." ;; Avoid calling point-motion-hooks recursively. (let ((inhibit-point-motion-hooks t)) - (unless table-cell-entered-state - (setq table-cell-entered-state t) + (force-mode-line-update) + (pcase dir + ('left + (setq table-mode-indicator nil) + (run-hooks 'table-point-left-cell-hook)) + ('entered (setq table-mode-indicator t) - (force-mode-line-update) (table--warn-incompatibility) - (run-hooks 'table-point-entered-cell-hook)))) - -(defun table--point-left-cell-function (&optional _old-point _new-point) - "Point has left a cell. -Refresh the menu bar." - ;; Avoid calling point-motion-hooks recursively. - (let ((inhibit-point-motion-hooks t)) - (when table-cell-entered-state - (setq table-cell-entered-state nil) - (setq table-mode-indicator nil) - (force-mode-line-update) - (run-hooks 'table-point-left-cell-hook)))) + (run-hooks 'table-point-entered-cell-hook))))) (defun table--warn-incompatibility () "If called from interactive operation warn the know incompatibilities. diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index e9c7e2f114e..274cb4aa434 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -1331,7 +1331,9 @@ inserts \" characters." (goto-char saved) (insert (if (> saved (mark)) tex-close-quote tex-open-quote))) (if (or (memq (char-syntax (preceding-char)) '(?\( ?> ?\s)) - (memq (preceding-char) '(?~))) + (memq (preceding-char) '(?~ ?'))) + ;; We're in an "opening" context + ;; (if electric-pair-mode (if (looking-at (regexp-quote tex-close-quote)) (forward-char (length tex-close-quote)) @@ -1339,6 +1341,8 @@ inserts \" characters." (insert tex-close-quote) (backward-char (length tex-close-quote))) (insert tex-open-quote)) + ;; We're in a "closing" context. + ;; (if (looking-at (regexp-quote tex-close-quote)) (forward-char (length tex-close-quote)) (insert tex-close-quote)))))) @@ -1761,13 +1765,13 @@ Mark is left at original location." ;; A better way to handle this, \( .. \) etc, is probably to ;; temporarily change the syntax of the \ in \( to punctuation. ((and latex-handle-escaped-parens - (looking-back "\\\\[])}]")) + (looking-back "\\\\[])}]" (- (point) 2))) (signal 'scan-error (list "Containing expression ends prematurely" (- (point) 2) (prog1 (point) (goto-char pos))))) ((and latex-handle-escaped-parens - (looking-back "\\\\\\([({[]\\)")) + (looking-back "\\\\\\([({[]\\)" (- (point) 2))) (tex-next-unmatched-eparen (match-string 1))) (t (goto-char newpos)))))) diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el index 84b578b5059..7effa6ade59 100644 --- a/lisp/textmodes/text-mode.el +++ b/lisp/textmodes/text-mode.el @@ -29,7 +29,9 @@ ;;; Code: -(defcustom text-mode-hook nil +;; Normally non-nil defaults for hooks are bad, but since this file is +;; preloaded it's ok/better, and avoids this showing up in customize-rogue. +(defcustom text-mode-hook '(text-mode-hook-identify) "Normal hook run when entering Text mode and many related modes." :type 'hook :options '(turn-on-auto-fill turn-on-flyspell) @@ -153,8 +155,6 @@ Turning on Paragraph-Indent minor mode runs the normal hook This is how `toggle-text-mode-auto-fill' knows which buffers to operate on." (set (make-local-variable 'text-mode-variant) t)) -(add-hook 'text-mode-hook 'text-mode-hook-identify) - (defun toggle-text-mode-auto-fill () "Toggle whether to use Auto Fill in Text mode and related modes. This command affects all buffers that use modes related to Text mode, |
