Skip to content

Commit

Permalink
Merge pull request emacs-mirror#19 from masm11/minimize-gtkutil-diff
Browse files Browse the repository at this point in the history
Minimize gtkutil diff
  • Loading branch information
Yuuki Harano authored Mar 31, 2020
2 parents baed679 + bd6fe60 commit f88789b
Show file tree
Hide file tree
Showing 6 changed files with 1,028 additions and 1,057 deletions.
44 changes: 24 additions & 20 deletions lisp/dired.el
Original file line number Diff line number Diff line change
Expand Up @@ -1208,15 +1208,11 @@ wildcards, erases the buffer, and builds the subdir-alist anew

;; default-directory and dired-actual-switches must be buffer-local
;; and initialized by now.
(let (dirname
;; This makes read-in much faster.
;; In particular, it prevents the font lock hook from running
;; until the directory is all read in.
(inhibit-modification-hooks t))
(if (consp dired-directory)
(setq dirname (car dired-directory))
(setq dirname dired-directory))
(setq dirname (expand-file-name dirname))
(let ((dirname
(expand-file-name
(if (consp dired-directory)
(car dired-directory)
dired-directory))))
(save-excursion
;; This hook which may want to modify dired-actual-switches
;; based on dired-directory, e.g. with ange-ftp to a SysV host
Expand All @@ -1226,17 +1222,25 @@ wildcards, erases the buffer, and builds the subdir-alist anew
(setq buffer-undo-list nil))
(setq-local file-name-coding-system
(or coding-system-for-read file-name-coding-system))
(let ((inhibit-read-only t)
;; Don't make undo entries for readin.
(buffer-undo-list t))
(widen)
(erase-buffer)
(dired-readin-insert))
(goto-char (point-min))
;; Must first make alist buffer local and set it to nil because
;; dired-build-subdir-alist will call dired-clear-alist first
(setq-local dired-subdir-alist nil)
(dired-build-subdir-alist)
(widen)
;; We used to bind `inhibit-modification-hooks' to try and speed up
;; execution, in particular, to prevent the font-lock hook from running
;; until the directory is all read in.
;; I strongly suspect that this was only useful in Emacs<21, because
;; jit-lock made it a non-issue.
;; Nevertheless, I used `combine-change-calls' which provides the
;; same performance advantages, just in case.
(combine-change-calls (point-min) (point-max)
(let ((inhibit-read-only t)
;; Don't make undo entries for readin.
(buffer-undo-list t))
(erase-buffer)
(dired-readin-insert))
(goto-char (point-min))
;; Must first make alist buffer local and set it to nil because
;; dired-build-subdir-alist will call dired-clear-alist first
(setq-local dired-subdir-alist nil)
(dired-build-subdir-alist))
(let ((attributes (file-attributes dirname)))
(if (eq (car attributes) t)
(set-visited-file-modtime (file-attribute-modification-time
Expand Down
118 changes: 60 additions & 58 deletions lisp/minibuffer.el
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,7 @@ variables.")
(plist-get completion-extra-properties
:annotation-function)
completion-annotate-function))
(mainbuf (current-buffer))
;; If the *Completions* buffer is shown in a new
;; window, mark it as softly-dedicated, so bury-buffer in
;; minibuffer-hide-completions will know whether to
Expand All @@ -1987,67 +1988,68 @@ variables.")
,(if (eq (selected-window) (minibuffer-window))
'display-buffer-at-bottom
'display-buffer-below-selected))
,(if temp-buffer-resize-mode
'(window-height . resize-temp-buffer-window)
'(window-height . fit-window-to-buffer))
,(when temp-buffer-resize-mode
'(preserve-size . (nil . t)))
,(if temp-buffer-resize-mode
'(window-height . resize-temp-buffer-window)
'(window-height . fit-window-to-buffer))
,(when temp-buffer-resize-mode
'(preserve-size . (nil . t)))
(body-function
. ,#'(lambda (_window)
;; Remove the base-size tail because `sort' requires a properly
;; nil-terminated list.
(when last (setcdr last nil))
(setq completions
;; FIXME: This function is for the output of all-completions,
;; not completion-all-completions. Often it's the same, but
;; not always.
(let ((sort-fun (completion-metadata-get
all-md 'display-sort-function)))
(if sort-fun
(funcall sort-fun completions)
(sort completions 'string-lessp))))
(when afun
(with-current-buffer mainbuf
;; Remove the base-size tail because `sort' requires a properly
;; nil-terminated list.
(when last (setcdr last nil))
(setq completions
(mapcar (lambda (s)
(let ((ann (funcall afun s)))
(if ann (list s ann) s)))
completions)))

(with-current-buffer standard-output
(set (make-local-variable 'completion-base-position)
(list (+ start base-size)
;; FIXME: We should pay attention to completion
;; boundaries here, but currently
;; completion-all-completions does not give us the
;; necessary information.
end))
(set (make-local-variable 'completion-list-insert-choice-function)
(let ((ctable minibuffer-completion-table)
(cpred minibuffer-completion-predicate)
(cprops completion-extra-properties))
(lambda (start end choice)
(unless (or (zerop (length prefix))
(equal prefix
(buffer-substring-no-properties
(max (point-min)
(- start (length prefix)))
start)))
(message "*Completions* out of date"))
;; FIXME: Use `md' to do quoting&terminator here.
(completion--replace start end choice)
(let* ((minibuffer-completion-table ctable)
(minibuffer-completion-predicate cpred)
(completion-extra-properties cprops)
(result (concat prefix choice))
(bounds (completion-boundaries
result ctable cpred "")))
;; If the completion introduces a new field, then
;; completion is not finished.
(completion--done result
(if (eq (car bounds) (length result))
'exact 'finished)))))))

(display-completion-list completions))))
;; FIXME: This function is for the output of all-completions,
;; not completion-all-completions. Often it's the same, but
;; not always.
(let ((sort-fun (completion-metadata-get
all-md 'display-sort-function)))
(if sort-fun
(funcall sort-fun completions)
(sort completions 'string-lessp))))
(when afun
(setq completions
(mapcar (lambda (s)
(let ((ann (funcall afun s)))
(if ann (list s ann) s)))
completions)))

(with-current-buffer standard-output
(set (make-local-variable 'completion-base-position)
(list (+ start base-size)
;; FIXME: We should pay attention to completion
;; boundaries here, but currently
;; completion-all-completions does not give us the
;; necessary information.
end))
(set (make-local-variable 'completion-list-insert-choice-function)
(let ((ctable minibuffer-completion-table)
(cpred minibuffer-completion-predicate)
(cprops completion-extra-properties))
(lambda (start end choice)
(unless (or (zerop (length prefix))
(equal prefix
(buffer-substring-no-properties
(max (point-min)
(- start (length prefix)))
start)))
(message "*Completions* out of date"))
;; FIXME: Use `md' to do quoting&terminator here.
(completion--replace start end choice)
(let* ((minibuffer-completion-table ctable)
(minibuffer-completion-predicate cpred)
(completion-extra-properties cprops)
(result (concat prefix choice))
(bounds (completion-boundaries
result ctable cpred "")))
;; If the completion introduces a new field, then
;; completion is not finished.
(completion--done result
(if (eq (car bounds) (length result))
'exact 'finished)))))))

(display-completion-list completions)))))
nil)))
nil))

Expand Down
Loading

0 comments on commit f88789b

Please sign in to comment.