Merge from origin/emacs-26
1e5949642a
; * src/gtkutil.c (xg_create_frame_widgets): Add FIXME re....e7c8da4d05
bug#28609: simple.el827db6b559
Use a separate syntax-ppss cache for narrowed buffersa2244f417a
Improve python3-compatibility of fallback completion (Bug#...79162cb0db
Fix subr-x-tests when running from elc66d35ae49d
* lisp/eshell/esh-util.el (eshell-condition-case): Add deb...f5e72b04d9
Make sh-indentation into an alias for sh-basic-offset (Bug...a58d0c590a
Fix loading of smie-config rules (Bug#24848)3a68dec327
; Update NEWS for the change in eldoc-message5a41dd0a1f
Reset default-directory inside *xref-grep* buffer49cd561dc6
* test/lisp/tramp-tests.el (tramp-test21-file-links): Spec...b719f6b20b
Loosen strict parsing requirement for desktop filesc7a0c13777
* lisp/xdg.el (xdg-thumb-uri): Fix doc string.dc6b3560e5
Fix documentation of `make-frame' and related variables an...3d3778d82a
Accept new `always' value for option `buffer-offer-save'638f64c40a
Improve new NS scrolling variable namesd93301242f
Document 'replace-buffer-contents' in the manual.00e4e3e9d2
Fix undecorated frame resizing issues on NS (bug#28512)820739bbb5
; * doc/emacs/display.texi (Display Custom): Fix wording.f2b2201594
; Spelling and URL fixes0e143b1fc5
Documentation improvements for 'display-line-numbers'f656ccdb43
; Fix typod64da52d57
Fix last change in bat-mode.el908af46abd
Fix restoring in GUI sessions desktop saved in TTY sessions51cbd85454
Improve syntax highlighting in bat-mode0273916618
Document the 'list-FOO' conventiond24ec58540
Expose viewing conditions in CAM02-UCS metrica81d5a3d3f
Revert "Set frame size to actual requested size (bug#18215)"0bf066d4b2
Add tests for Edebug68baca3ee1
Catch more messages in ert-with-message-capture28e0c410c9
; * lisp/mouse.el (secondary-selection-exist-p): Doc fix.31e1d9ef2f
Support setting region from secondary selection and vice v...047f02f00f
Fix new copy-directory bug with empty dirsfbd15836af
* doc/lispref/strings.texi (Formatting Strings): Improve i...f16a8d5dbd
Fix 2 testsuite tests for MS-Windows965cffd89c
Rename timer-list to list-timersa5fec62b51
Provide native touchpad scrolling on macOS7b3d1c6beb
Fix MinGW64 build broken by recent MinGW64 import librariesc83d0c5fdf
Fix crashes in 'move-point-visually' in minibuffer windows7f3d5f929d
* src/emacs.c (usage_message): Don't mention 'find-file'.6845282200
Fix a minor inaccuracy in the Emacs manual74d7bb9498
Fix errors in flyspell-post-command-hook40fdbb01d0
Work on Tramp's file-truename1a01423b3c
Fix bug with make-directory on MS-Windows root066efb8666
Fix log-view-diff-common when point is after last entry3f006b56cd
Adapt fileio-tests--symlink-failure to Cygwinee512e9a82
Ignore buffers whose name begins with a space in save-some...9e1b5bd92c
Improve tramp-interrupt-process robustness8d4223e61b
Minor Tramp doc update331d0e520f
Fix gensym466df76f7d
Cleanup in files-tests.el6359fe630a
Remove old cl-assert calls in 'newline'059184e645
Avoid crash with C-g C-g in GC541006c536
Fix format-time-string %Z bug with negative tz679e05eeb9
message-citation-line-format %Z is now tz name4e8888d438
Use doc-view or pdf-tools on any window-system5f28f0db73
Fix bug with min and max and NaNs37b5e661d2
Fix recently-introduced copy-directory bug6bbbc38b34
Merge from Gnulib57249fb297
Fix compatibility problem in Tramp411bec82c4
Avoid GCC 7 compilation warning in eval.c34a6774daa
; Partially revertc3445aed51
3003ac0469
Adapt Tramp version. Do not merge48d39c39e8
Search for Syntax section when viewing MDN9d101376b4
Allow smerge-keep-current to work for empty hunks13aba24add
Call vc-setup-buffer in vc-git-log-{in,out}going1d599df5e0
Fix last change to textmodes/page-ext.ela726e09a9a
* test/src/lcms-tests.el (lcms-cri-cam02-ucs): Skip if lcm...546413e1ac
* test/src/lcms-tests.el (lcms-whitepoint): Skip if lcms2 ...96aaeaaffa
; * src/lcms.c: Minor stylistic changes in comments.c3df816585
Fix compilation warning in etags.c
This commit is contained in:
commit
98ac36efe4
9 changed files with 113 additions and 62 deletions
|
@ -1956,7 +1956,7 @@ E.g. provided via a file-local call to `smie-config-local'.")
|
|||
(defvar smie-config--modefuns nil)
|
||||
|
||||
(defun smie-config--setter (var value)
|
||||
(setq-default var value)
|
||||
(set-default var value)
|
||||
(let ((old-modefuns smie-config--modefuns))
|
||||
(setq smie-config--modefuns nil)
|
||||
(pcase-dolist (`(,mode . ,rules) value)
|
||||
|
@ -1982,7 +1982,7 @@ value with which to replace it."
|
|||
;; FIXME improve value-type.
|
||||
:type '(choice (const nil)
|
||||
(alist :key-type symbol))
|
||||
:initialize 'custom-initialize-default
|
||||
:initialize 'custom-initialize-set
|
||||
:set #'smie-config--setter)
|
||||
|
||||
(defun smie-config-local (rules)
|
||||
|
|
|
@ -381,10 +381,26 @@ This function should move the cursor back to some syntactically safe
|
|||
point (where the PPSS is equivalent to nil).")
|
||||
(make-obsolete-variable 'syntax-begin-function nil "25.1")
|
||||
|
||||
(defvar-local syntax-ppss-cache nil
|
||||
"List of (POS . PPSS) pairs, in decreasing POS order.")
|
||||
(defvar-local syntax-ppss-last nil
|
||||
"Cache of (LAST-POS . LAST-PPSS).")
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Several caches.
|
||||
;;
|
||||
;; Because `syntax-ppss' is equivalent to (parse-partial-sexp
|
||||
;; (POINT-MIN) x), we need either to empty the cache when we narrow
|
||||
;; the buffer, which is suboptimal, or we need to use several caches.
|
||||
;; We use two of them, one for widened buffer, and one for narrowing.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defvar-local syntax-ppss-wide nil
|
||||
"Cons of two elements (LAST . CACHE).
|
||||
Where LAST is a pair (LAST-POS . LAST-PPS) caching the last invocation
|
||||
and CACHE is a list of (POS . PPSS) pairs, in decreasing POS order.
|
||||
These are valid when the buffer has no restriction.")
|
||||
|
||||
(defvar-local syntax-ppss-narrow nil
|
||||
"Same as `syntax-ppss-wide' but for a narrowed buffer.")
|
||||
|
||||
(defvar-local syntax-ppss-narrow-start nil
|
||||
"Start position of the narrowing for `syntax-ppss-narrow'.")
|
||||
|
||||
(defalias 'syntax-ppss-after-change-function 'syntax-ppss-flush-cache)
|
||||
(defun syntax-ppss-flush-cache (beg &rest ignored)
|
||||
|
@ -392,24 +408,29 @@ point (where the PPSS is equivalent to nil).")
|
|||
;; Set syntax-propertize to refontify anything past beg.
|
||||
(setq syntax-propertize--done (min beg syntax-propertize--done))
|
||||
;; Flush invalid cache entries.
|
||||
(while (and syntax-ppss-cache (> (caar syntax-ppss-cache) beg))
|
||||
(setq syntax-ppss-cache (cdr syntax-ppss-cache)))
|
||||
;; Throw away `last' value if made invalid.
|
||||
(when (< beg (or (car syntax-ppss-last) 0))
|
||||
;; If syntax-begin-function jumped to BEG, then the old state at BEG can
|
||||
;; depend on the text after BEG (which is presumably changed). So if
|
||||
;; BEG=(car (nth 10 syntax-ppss-last)) don't reuse that data because the
|
||||
;; assumed nil state at BEG may not be valid any more.
|
||||
(if (<= beg (or (syntax-ppss-toplevel-pos (cdr syntax-ppss-last))
|
||||
(nth 3 syntax-ppss-last)
|
||||
0))
|
||||
(setq syntax-ppss-last nil)
|
||||
(setcar syntax-ppss-last nil)))
|
||||
;; Unregister if there's no cache left. Sadly this doesn't work
|
||||
;; because `before-change-functions' is temporarily bound to nil here.
|
||||
;; (unless syntax-ppss-cache
|
||||
;; (remove-hook 'before-change-functions 'syntax-ppss-flush-cache t))
|
||||
)
|
||||
(dolist (cell (list syntax-ppss-wide syntax-ppss-narrow))
|
||||
(pcase cell
|
||||
(`(,last . ,cache)
|
||||
(while (and cache (> (caar cache) beg))
|
||||
(setq cache (cdr cache)))
|
||||
;; Throw away `last' value if made invalid.
|
||||
(when (< beg (or (car last) 0))
|
||||
;; If syntax-begin-function jumped to BEG, then the old state at BEG can
|
||||
;; depend on the text after BEG (which is presumably changed). So if
|
||||
;; BEG=(car (nth 10 syntax-ppss-last)) don't reuse that data because the
|
||||
;; assumed nil state at BEG may not be valid any more.
|
||||
(if (<= beg (or (syntax-ppss-toplevel-pos (cdr last))
|
||||
(nth 3 last)
|
||||
0))
|
||||
(setq last nil)
|
||||
(setcar last nil)))
|
||||
;; Unregister if there's no cache left. Sadly this doesn't work
|
||||
;; because `before-change-functions' is temporarily bound to nil here.
|
||||
;; (unless cache
|
||||
;; (remove-hook 'before-change-functions 'syntax-ppss-flush-cache t))
|
||||
(setcar cell last)
|
||||
(setcdr cell cache)))
|
||||
))
|
||||
|
||||
(defvar syntax-ppss-stats
|
||||
[(0 . 0.0) (0 . 0.0) (0 . 0.0) (0 . 0.0) (0 . 0.0) (1 . 2500.0)])
|
||||
|
@ -423,6 +444,17 @@ point (where the PPSS is equivalent to nil).")
|
|||
(defvar-local syntax-ppss-table nil
|
||||
"Syntax-table to use during `syntax-ppss', if any.")
|
||||
|
||||
(defun syntax-ppss--data ()
|
||||
(if (eq (point-min) 1)
|
||||
(progn
|
||||
(unless syntax-ppss-wide
|
||||
(setq syntax-ppss-wide (cons nil nil)))
|
||||
syntax-ppss-wide)
|
||||
(unless (eq syntax-ppss-narrow-start (point-min))
|
||||
(setq syntax-ppss-narrow-start (point-min))
|
||||
(setq syntax-ppss-narrow (cons nil nil)))
|
||||
syntax-ppss-narrow))
|
||||
|
||||
(defun syntax-ppss (&optional pos)
|
||||
"Parse-Partial-Sexp State at POS, defaulting to point.
|
||||
The returned value is the same as that of `parse-partial-sexp'
|
||||
|
@ -439,10 +471,13 @@ running the hook."
|
|||
(syntax-propertize pos)
|
||||
;;
|
||||
(with-syntax-table (or syntax-ppss-table (syntax-table))
|
||||
(let ((old-ppss (cdr syntax-ppss-last))
|
||||
(old-pos (car syntax-ppss-last))
|
||||
(ppss nil)
|
||||
(pt-min (point-min)))
|
||||
(let* ((cell (syntax-ppss--data))
|
||||
(ppss-last (car cell))
|
||||
(ppss-cache (cdr cell))
|
||||
(old-ppss (cdr ppss-last))
|
||||
(old-pos (car ppss-last))
|
||||
(ppss nil)
|
||||
(pt-min (point-min)))
|
||||
(if (and old-pos (> old-pos pos)) (setq old-pos nil))
|
||||
;; Use the OLD-POS if usable and close. Don't update the `last' cache.
|
||||
(condition-case nil
|
||||
|
@ -475,7 +510,7 @@ running the hook."
|
|||
;; The OLD-* data can't be used. Consult the cache.
|
||||
(t
|
||||
(let ((cache-pred nil)
|
||||
(cache syntax-ppss-cache)
|
||||
(cache ppss-cache)
|
||||
(pt-min (point-min))
|
||||
;; I differentiate between PT-MIN and PT-BEST because
|
||||
;; I feel like it might be important to ensure that the
|
||||
|
@ -491,7 +526,7 @@ running the hook."
|
|||
(if cache (setq pt-min (caar cache) ppss (cdar cache)))
|
||||
|
||||
;; Setup the before-change function if necessary.
|
||||
(unless (or syntax-ppss-cache syntax-ppss-last)
|
||||
(unless (or ppss-cache ppss-last)
|
||||
(add-hook 'before-change-functions
|
||||
'syntax-ppss-flush-cache t t))
|
||||
|
||||
|
@ -541,7 +576,7 @@ running the hook."
|
|||
pt-min (setq pt-min (/ (+ pt-min pos) 2))
|
||||
nil nil ppss))
|
||||
(push (cons pt-min ppss)
|
||||
(if cache-pred (cdr cache-pred) syntax-ppss-cache)))
|
||||
(if cache-pred (cdr cache-pred) ppss-cache)))
|
||||
|
||||
;; Compute the actual return value.
|
||||
(setq ppss (parse-partial-sexp pt-min pos nil nil ppss))
|
||||
|
@ -562,13 +597,15 @@ running the hook."
|
|||
(if (> (- (caar cache-pred) pos) syntax-ppss-max-span)
|
||||
(push pair (cdr cache-pred))
|
||||
(setcar cache-pred pair))
|
||||
(if (or (null syntax-ppss-cache)
|
||||
(> (- (caar syntax-ppss-cache) pos)
|
||||
(if (or (null ppss-cache)
|
||||
(> (- (caar ppss-cache) pos)
|
||||
syntax-ppss-max-span))
|
||||
(push pair syntax-ppss-cache)
|
||||
(setcar syntax-ppss-cache pair)))))))))
|
||||
(push pair ppss-cache)
|
||||
(setcar ppss-cache pair)))))))))
|
||||
|
||||
(setq syntax-ppss-last (cons pos ppss))
|
||||
(setq ppss-last (cons pos ppss))
|
||||
(setcar cell ppss-last)
|
||||
(setcdr cell ppss-cache)
|
||||
ppss)
|
||||
(args-out-of-range
|
||||
;; If the buffer is more narrowed than when we built the cache,
|
||||
|
@ -582,7 +619,7 @@ running the hook."
|
|||
(defun syntax-ppss-debug ()
|
||||
(let ((pt nil)
|
||||
(min-diffs nil))
|
||||
(dolist (x (append syntax-ppss-cache (list (cons (point-min) nil))))
|
||||
(dolist (x (append (cdr (syntax-ppss--data)) (list (cons (point-min) nil))))
|
||||
(when pt (push (- pt (car x)) min-diffs))
|
||||
(setq pt (car x)))
|
||||
min-diffs))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue