commit ce085f1d61a69e9e407a31d60c298f04cbd0c8d2 (HEAD, refs/remotes/origin/master) Author: Stefan Monnier Date: Fri Jan 25 16:15:22 2019 -0500 * lisp/loadup.el (load-file-name): Set back to nil diff --git a/lisp/loadup.el b/lisp/loadup.el index 100c3f700d..747476c506 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -534,6 +534,10 @@ lost after dumping"))) (equal (nth 2 command-line-args) "loadup")) (setcdr command-line-args (nthcdr 3 command-line-args))) +;; Don't keep `load-file-name' set during the top-level session! +;; Otherwise, it breaks a lot of code which does things like +;; (or load-file-name byte-compile-current-file). +(setq load-file-name nil) (eval top-level) commit 682ab5d92a6922694a92fcde029811bccf98d700 Author: João Távora Date: Fri Jan 25 13:04:13 2019 +0000 Adjust previous electric.el and elec-pair.el change This fixes a serious bug introduced previously electric-pair-inhibit-if-helps-balance and electric-pair-skip-if-helps-balance, whereby "innocent" markers were being pushed by those function's new save-change-and-restore semantics. The fix can probably still be improved. It also adds comments to parts of the code, where deemed necessary. * lisp/elec-pair.el (electric-pair--insert): Add comment. (electric-pair--save-literal-point-excursion): New helper macro. (electric-pair-inhibit-if-helps-balance) (electric-pair-skip-if-helps-balance): Don't use insert-before-markers since it may hurt other markers that have nothing to do with the 'save-excursion'. (electric-pair-post-self-insert-function): Use electric-pair--save-literal-point-excursion. * lisp/electric.el (electric-indent-post-self-insert-function): Remove lexical variable. diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el index 20581ad657..b5ec492930 100644 --- a/lisp/elec-pair.el +++ b/lisp/elec-pair.el @@ -228,6 +228,12 @@ inside a comment or string." (let ((last-command-event char) (blink-matching-paren nil) (electric-pair-mode nil) + ;; When adding the "closer" delimiter, a job his function is + ;; frequently used for, we don't want to munch any extra + ;; newlines above us. That would be the default behaviour of + ;; `electric-layout-mode', which potentially kicked in before + ;; us to add these newlines, and is probably about to kick in + ;; again after we add the closer. (electric-layout-allow-duplicate-newlines t)) (self-insert-command 1))) @@ -406,6 +412,15 @@ strings." (let ((ppss (electric-pair--syntax-ppss (point) '(comment)))) (memq (nth 3 ppss) (list t char)))) +(defmacro electric-pair--save-literal-point-excursion (&rest body) + ;; FIXME: need this instead of `save-excursion' when functions in + ;; BODY, such as `electric-pair-inhibit-if-helps-balance' and + ;; `electric-pair-skip-if-helps-balance' modify and restore the + ;; buffer in a way that modifies the marker used by save-excursion. + (let ((point (make-symbol "point"))) + `(let ((,point (point))) + (unwind-protect (progn ,@body) (goto-char ,point))))) + (defun electric-pair-inhibit-if-helps-balance (char) "Return non-nil if auto-pairing of CHAR would hurt parentheses' balance. @@ -427,7 +442,7 @@ happened." (eq (cdr outermost) pair))))) ((eq syntax ?\") (electric-pair--unbalanced-strings-p char)))) - (insert-before-markers char))))) + (insert char))))) (defun electric-pair-skip-if-helps-balance (char) "Return non-nil if skipping CHAR would benefit parentheses' balance. @@ -452,7 +467,7 @@ happened." (not (eq (cdr outermost) pair))))))) ((eq syntax ?\") (electric-pair--inside-string-p char)))) - (insert-before-markers char))))) + (insert char))))) (defun electric-pair-default-skip-self (char) (if electric-pair-preserve-balance @@ -498,7 +513,7 @@ happened." ((and (memq syntax '(?\) ?\" ?\$)) (and (or unconditional (if (functionp electric-pair-skip-self) - (save-excursion + (electric-pair--save-literal-point-excursion (goto-char pos) (funcall electric-pair-skip-self last-command-event)) electric-pair-skip-self)) @@ -527,7 +542,7 @@ happened." ((and (memq syntax '(?\( ?\" ?\$)) (not overwrite-mode) (or unconditional - (not (save-excursion + (not (electric-pair--save-literal-point-excursion (goto-char pos) (funcall electric-pair-inhibit-predicate last-command-event))))) @@ -544,6 +559,11 @@ happened." (matching-paren (char-after)))) (save-excursion (newline 1 t))))))) +;; Prioritize this to kick in after +;; `electric-layout-post-self-insert-function': that considerably +;; simplifies interoperation when `electric-pair-mode', +;; `electric-layout-mode' and `electric-indent-mode' are used +;; together. Use `vc-region-history' on these lines for more info. (put 'electric-pair-post-self-insert-function 'priority 50) (defun electric-pair-will-use-region () diff --git a/lisp/electric.el b/lisp/electric.el index b9458776e3..657913a396 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -270,14 +270,12 @@ or comment." ;; hence copied). (let ((at-newline (<= pos (line-beginning-position)))) (when at-newline - (let ((before (copy-marker (1- pos) t)) - inhibit-reindentation) + (let ((before (copy-marker (1- pos) t))) (save-excursion (unless - (setq inhibit-reindentation - (or (memq indent-line-function - electric-indent-functions-without-reindent) - electric-indent-inhibit)) + (or (memq indent-line-function + electric-indent-functions-without-reindent) + electric-indent-inhibit) ;; Don't reindent the previous line if the ;; indentation function is not a real one. (goto-char before) commit f845f8a279cfc2acd1051b4cd4924e2aede54017 Author: João Távora Date: Thu Jan 24 18:04:52 2019 +0000 Use minibuffer-default in completion-all-sorted-completions (bug#34083) * lisp/minibuffer (completion-all-sorted-completions): Sort with the default on top. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index c8b84b0e94..b757eb8a5a 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1244,12 +1244,16 @@ scroll the window of possible completions." (setq all (if sort-fun (funcall sort-fun all) ;; Prefer shorter completions, by default. (sort all (lambda (c1 c2) (< (length c1) (length c2)))))) - ;; Prefer recently used completions. + ;; Prefer recently used completions and put the default, if + ;; it exists, on top. (when (minibufferp) (let ((hist (symbol-value minibuffer-history-variable))) - (setq all (sort all (lambda (c1 c2) - (> (length (member c1 hist)) - (length (member c2 hist)))))))) + (setq all (sort all + (lambda (c1 c2) + (cond ((equal c1 minibuffer-default) t) + ((equal c2 minibuffer-default) nil) + (t (> (length (member c1 hist)) + (length (member c2 hist)))))))))) ;; Cache the result. This is not just for speed, but also so that ;; repeated calls to minibuffer-force-complete can cycle through ;; all possibilities.