diff options
| author | Lars Ingebrigtsen | 2019-06-18 15:24:10 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-06-18 15:24:10 +0200 |
| commit | 6a02ca0b8c055c863bf53d9b92e8bea27b0e992f (patch) | |
| tree | 91453ba090fadcc09e6c86f060e8b6c1d6b558a1 | |
| parent | 29ea0803d7fa927a537ce8437944998bf2e0807e (diff) | |
| download | emacs-6a02ca0b8c055c863bf53d9b92e8bea27b0e992f.tar.gz emacs-6a02ca0b8c055c863bf53d9b92e8bea27b0e992f.zip | |
Report progress during custom-make-dependencies instead of file count
* lisp/cus-dep.el (custom-make-dependencies): Rewrite to use
reporter to report progress instead of how many files we've
processed.
* lisp/emacs-lisp/byte-run.el (byte-compile-info-string): New function.
(byte-compile-info-message): Use it.
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/cus-dep.el | 132 | ||||
| -rw-r--r-- | lisp/emacs-lisp/byte-run.el | 6 |
3 files changed, 79 insertions, 63 deletions
| @@ -1701,6 +1701,10 @@ valid event type. | |||
| 1701 | ** The new macro `with-suppressed-warnings' can be used to suppress | 1701 | ** The new macro `with-suppressed-warnings' can be used to suppress |
| 1702 | specific byte-compile warnings. | 1702 | specific byte-compile warnings. |
| 1703 | 1703 | ||
| 1704 | --- | ||
| 1705 | ** The new function `byte-compile-info-message' can be used to output | ||
| 1706 | informational messages that look pleasing during the Emacs build. | ||
| 1707 | |||
| 1704 | +++ | 1708 | +++ |
| 1705 | ** The 'append' arg of 'add-hook' is generalized to a finer notion of 'depth' | 1709 | ** The 'append' arg of 'add-hook' is generalized to a finer notion of 'depth' |
| 1706 | This makes it possible to control the ordering of functions more precisely, | 1710 | This makes it possible to control the ordering of functions more precisely, |
diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el index 161c5bbec69..05a01115957 100644 --- a/lisp/cus-dep.el +++ b/lisp/cus-dep.el | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | (require 'widget) | 28 | (require 'widget) |
| 29 | (require 'cus-face) | 29 | (require 'cus-face) |
| 30 | (require 'cl-lib) | ||
| 30 | 31 | ||
| 31 | (defvar generated-custom-dependencies-file "cus-load.el" | 32 | (defvar generated-custom-dependencies-file "cus-load.el" |
| 32 | "Output file for `custom-make-dependencies'.") | 33 | "Output file for `custom-make-dependencies'.") |
| @@ -53,72 +54,79 @@ ldefs-boot\\|cus-load\\|finder-inf\\|esh-groups\\|subdirs\\)\\.el$\\)" | |||
| 53 | (defun custom-make-dependencies () | 54 | (defun custom-make-dependencies () |
| 54 | "Batch function to extract custom dependencies from .el files. | 55 | "Batch function to extract custom dependencies from .el files. |
| 55 | Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS" | 56 | Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS" |
| 56 | (let ((enable-local-eval nil) | 57 | (let* ((enable-local-eval nil) |
| 57 | (enable-local-variables :safe) | 58 | (enable-local-variables :safe) |
| 58 | (file-count 0) | 59 | (preloaded (concat "\\`\\(\\./+\\)?" |
| 59 | subdir) | 60 | (regexp-opt preloaded-file-list t) |
| 61 | "\\.el\\'")) | ||
| 62 | (file-count 0) | ||
| 63 | (files | ||
| 64 | ;; Use up command-line-args-left else Emacs can try to open | ||
| 65 | ;; the args as directories after we are done. | ||
| 66 | (cl-loop for subdir = (pop command-line-args-left) | ||
| 67 | while subdir | ||
| 68 | append (mapcar (lambda (f) | ||
| 69 | (cons subdir f)) | ||
| 70 | (directory-files subdir nil | ||
| 71 | "\\`[^=.].*\\.el\\'")))) | ||
| 72 | (progress (make-progress-reporter | ||
| 73 | (byte-compile-info-string "Scanning files for custom") | ||
| 74 | 0 (length files) nil 10))) | ||
| 60 | (with-temp-buffer | 75 | (with-temp-buffer |
| 61 | ;; Use up command-line-args-left else Emacs can try to open | 76 | (dolist (elem files) |
| 62 | ;; the args as directories after we are done. | 77 | (let* ((subdir (car elem)) |
| 63 | (while (setq subdir (pop command-line-args-left)) | 78 | (file (cdr elem)) |
| 64 | (let ((files (directory-files subdir nil "\\`[^=.].*\\.el\\'")) | 79 | (default-directory |
| 65 | (default-directory | 80 | (directory-file-name (expand-file-name subdir)))) |
| 66 | (file-name-as-directory (expand-file-name subdir))) | 81 | (progress-reporter-update progress (setq file-count (1+ file-count))) |
| 67 | (preloaded (concat "\\`\\(\\./+\\)?" | 82 | (unless (or (string-match custom-dependencies-no-scan-regexp file) |
| 68 | (regexp-opt preloaded-file-list t) | 83 | (string-match preloaded (format "%s/%s" subdir file)) |
| 69 | "\\.el\\'"))) | 84 | (not (file-exists-p file))) |
| 70 | (dolist (file files) | 85 | (erase-buffer) |
| 71 | (setq file-count (1+ file-count)) | 86 | (kill-all-local-variables) |
| 72 | (when (zerop (mod file-count 100)) | 87 | (insert-file-contents file) |
| 73 | (byte-compile-info-message "Scanned %s files for custom" | 88 | (hack-local-variables) |
| 74 | file-count)) | 89 | (goto-char (point-min)) |
| 75 | (unless (or (string-match custom-dependencies-no-scan-regexp file) | 90 | (string-match "\\`\\(.*\\)\\.el\\'" file) |
| 76 | (string-match preloaded (format "%s/%s" subdir file)) | 91 | (let ((name (or generated-autoload-load-name ; see bug#5277 |
| 77 | (not (file-exists-p file))) | 92 | (file-name-nondirectory (match-string 1 file)))) |
| 78 | (erase-buffer) | 93 | (load-file-name file)) |
| 79 | (kill-all-local-variables) | 94 | (if (save-excursion |
| 80 | (insert-file-contents file) | 95 | (re-search-forward |
| 81 | (hack-local-variables) | ||
| 82 | (goto-char (point-min)) | ||
| 83 | (string-match "\\`\\(.*\\)\\.el\\'" file) | ||
| 84 | (let ((name (or generated-autoload-load-name ; see bug#5277 | ||
| 85 | (file-name-nondirectory (match-string 1 file)))) | ||
| 86 | (load-file-name file)) | ||
| 87 | (if (save-excursion | ||
| 88 | (re-search-forward | ||
| 89 | (concat "(\\(cc-\\)?provide[ \t\n]+\\('\\|(quote[ \t\n]\\)[ \t\n]*" | 96 | (concat "(\\(cc-\\)?provide[ \t\n]+\\('\\|(quote[ \t\n]\\)[ \t\n]*" |
| 90 | (regexp-quote name) "[ \t\n)]") | 97 | (regexp-quote name) "[ \t\n)]") |
| 91 | nil t)) | 98 | nil t)) |
| 92 | (setq name (intern name))) | 99 | (setq name (intern name))) |
| 93 | (condition-case nil | 100 | (condition-case nil |
| 94 | (while (re-search-forward | 101 | (while (re-search-forward |
| 95 | "^(def\\(custom\\|face\\|group\\)" nil t) | 102 | "^(def\\(custom\\|face\\|group\\)" nil t) |
| 96 | (beginning-of-line) | 103 | (beginning-of-line) |
| 97 | (let ((type (match-string 1)) | 104 | (let ((type (match-string 1)) |
| 98 | (expr (read (current-buffer)))) | 105 | (expr (read (current-buffer)))) |
| 99 | (condition-case nil | 106 | (condition-case nil |
| 100 | (let ((custom-dont-initialize t)) | 107 | (let ((custom-dont-initialize t)) |
| 101 | ;; Eval to get the 'custom-group, -tag, | 108 | ;; Eval to get the 'custom-group, -tag, |
| 102 | ;; -version, group-documentation etc properties. | 109 | ;; -version, group-documentation etc properties. |
| 103 | (put (nth 1 expr) 'custom-where name) | 110 | (put (nth 1 expr) 'custom-where name) |
| 104 | (eval expr)) | 111 | (eval expr)) |
| 105 | ;; Eval failed for some reason. Eg maybe the | 112 | ;; Eval failed for some reason. Eg maybe the |
| 106 | ;; defcustom uses something defined earlier | 113 | ;; defcustom uses something defined earlier |
| 107 | ;; in the file (we haven't loaded the file). | 114 | ;; in the file (we haven't loaded the file). |
| 108 | ;; In most cases, we can still get the :group. | 115 | ;; In most cases, we can still get the :group. |
| 109 | (error | 116 | (error |
| 110 | (ignore-errors | 117 | (ignore-errors |
| 111 | (let ((group (cadr (memq :group expr)))) | 118 | (let ((group (cadr (memq :group expr)))) |
| 112 | (and group | 119 | (and group |
| 113 | (eq (car group) 'quote) | 120 | (eq (car group) 'quote) |
| 114 | (custom-add-to-group | 121 | (custom-add-to-group |
| 115 | (cadr group) | 122 | (cadr group) |
| 116 | (nth 1 expr) | 123 | (nth 1 expr) |
| 117 | (intern (format "custom-%s" | 124 | (intern (format "custom-%s" |
| 118 | (if (equal type "custom") | 125 | (if (equal type "custom") |
| 119 | "variable" | 126 | "variable" |
| 120 | type))))))))))) | 127 | type))))))))))) |
| 121 | (error nil))))))))) | 128 | (error nil))))))) |
| 129 | (progress-reporter-done progress)) | ||
| 122 | (byte-compile-info-message "Generating %s..." | 130 | (byte-compile-info-message "Generating %s..." |
| 123 | generated-custom-dependencies-file) | 131 | generated-custom-dependencies-file) |
| 124 | (set-buffer (find-file-noselect generated-custom-dependencies-file)) | 132 | (set-buffer (find-file-noselect generated-custom-dependencies-file)) |
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 96cff2ebeb2..d34d5d8a7e4 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el | |||
| @@ -540,9 +540,13 @@ Otherwise, return nil. For internal use only." | |||
| 540 | (mapconcat (lambda (char) (format "`?\\%c'" char)) | 540 | (mapconcat (lambda (char) (format "`?\\%c'" char)) |
| 541 | sorted ", "))))) | 541 | sorted ", "))))) |
| 542 | 542 | ||
| 543 | (defun byte-compile-info-string (&rest args) | ||
| 544 | "Format ARGS in a way that looks pleasing in the compilation output." | ||
| 545 | (format " %-9s%s" "INFO" (apply #'format args))) | ||
| 546 | |||
| 543 | (defun byte-compile-info-message (&rest args) | 547 | (defun byte-compile-info-message (&rest args) |
| 544 | "Message format ARGS in a way that looks pleasing in the compilation output." | 548 | "Message format ARGS in a way that looks pleasing in the compilation output." |
| 545 | (message " %-9s%s" "INFO" (apply #'format args))) | 549 | (message "%s" (apply #'byte-compile-info-string args))) |
| 546 | 550 | ||
| 547 | 551 | ||
| 548 | ;; I nuked this because it's not a good idea for users to think of using it. | 552 | ;; I nuked this because it's not a good idea for users to think of using it. |