commit c3f87efe3a73c2850f765773965b2440296b0666 (HEAD, refs/remotes/origin/master) Author: Alex Branham Date: Mon Feb 11 16:08:55 2019 -0600 Add basic conf-mode tests * test/lisp/textmodes/conf-mode-tests.el: New file with tests for conf-mode. Mostly taken from conf-mode docstrings. (Bug#34419) diff --git a/test/lisp/textmodes/conf-mode-tests.el b/test/lisp/textmodes/conf-mode-tests.el new file mode 100644 index 0000000000..5d79ceec96 --- /dev/null +++ b/test/lisp/textmodes/conf-mode-tests.el @@ -0,0 +1,204 @@ +;;; conf-mode-tests.el --- Test suite for conf mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2016-2019 Free Software Foundation, Inc. + +;; Author: J. Alexander Branham +;; Keywords: internal + +;; This file is part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: +(require 'conf-mode) +(require 'ert) + +(ert-deftest conf-test-align-assignments () + "Test for `conf-align-assignments'." + (with-temp-buffer + (insert "foo: bar\nbar: baz") + (conf-colon-mode) + (conf-align-assignments) + (should (equal (buffer-string) + "foo: bar\nbar: baz")))) + +(ert-deftest conf-test-font-lock () + (with-temp-buffer + (insert "foo: bar\nbar: baz") + (conf-colon-mode) + (font-lock-mode) + (font-lock-ensure) + (goto-char (point-min)) + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (search-forward "bar") + (should-not (face-at-point)))) + +(ert-deftest conf-test-windows-mode () + (with-temp-buffer + ;; from `conf-windows-mode' docstring: + (insert "[ExtShellFolderViews] +Default={5984FFE0-28D4-11CF-AE66-08002B2E1262} +{5984FFE0-28D4-11CF-AE66-08002B2E1262}={5984FFE0-28D4-11CF-AE66-08002B2E1262} + +[{5984FFE0-28D4-11CF-AE66-08002B2E1262}] +PersistMoniker=file://Folder.htt") + (goto-char (point-min)) + (conf-windows-mode) + (font-lock-mode) + (font-lock-ensure) + (search-forward "ExtShell") + (should (equal (face-at-point) 'font-lock-type-face)) + (search-forward "Defau") + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (forward-line) + (beginning-of-line) + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (forward-line 2) + (should-not (face-at-point)) + (forward-char) + (should (equal (face-at-point) 'font-lock-type-face)))) + +(ert-deftest conf-test-javaprop-mode () + (with-temp-buffer + ;; From `conf-javaprop-mode' docstring + (insert "// another kind of comment +/* yet another */ + +name:value +name=value +name value +x.1 = +x.2.y.1.z.1 = +x.2.y.1.z.2.zz =") + (goto-char (point-min)) + (conf-javaprop-mode) + (font-lock-mode) + (font-lock-ensure) + (should (equal (face-at-point) 'font-lock-comment-delimiter-face)) + (forward-char 3) + (should (equal (face-at-point) 'font-lock-comment-face)) + (search-forward "*") + (should (equal (face-at-point) 'font-lock-comment-delimiter-face)) + (while (search-forward "nam" nil t) + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (search-forward "val") + (should-not (face-at-point))) + (while (re-search-forward "a-z" nil t) + (backward-char) + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (re-search-forward "[0-0]" nil t) + (backward-char) + (should (equal (face-at-point) 'font-lock-constant-face))))) + +(ert-deftest conf-test-space-mode () + ;; From `conf-space-mode' docstring. + (with-temp-buffer + (insert "image/jpeg jpeg jpg jpe +image/png png +image/tiff tiff tif +") + (goto-char (point-min)) + (conf-space-mode) + (font-lock-mode) + (font-lock-ensure) + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (forward-char 15) + (should-not (face-at-point)))) + +(ert-deftest conf-test-colon-mode () + ;; From `conf-colon-mode' docstring. + (with-temp-buffer + (insert " : \"\\241\" exclamdown + : \"\\242\" cent") + (goto-char (point-min)) + (conf-colon-mode) + (font-lock-mode) + (font-lock-ensure) + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (search-forward "24") + (should (equal (face-at-point) 'font-lock-string-face)) + (forward-line) + (should (equal (face-at-point) 'font-lock-variable-name-face)))) + +(ert-deftest conf-test-ppd-mode () + ;; From `conf-ppd-mode' docstring. + (with-temp-buffer + (insert "*DefaultTransfer: Null +*Transfer Null.Inverse: \"{ 1 exch sub }\"") + (goto-char (point-min)) + (conf-ppd-mode) + (font-lock-mode) + (font-lock-ensure) + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (search-forward "Nul") + (should-not (face-at-point)))) + +(ert-deftest conf-test-xdefaults-mode () + ;; From `conf-xdefaults-mode' docstring. + (with-temp-buffer + (insert "*background: gray99 +*foreground: black") + (goto-char (point-min)) + (conf-xdefaults-mode) + (font-lock-mode) + (font-lock-ensure) + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (search-forward "gray") + (should-not (face-at-point)))) + +(ert-deftest conf-test-toml-mode () + ;; From `conf-toml-mode' docstring. + (with-temp-buffer + (insert "\[entry] +value = \"some string\"") + (goto-char (point-min)) + (conf-toml-mode) + (font-lock-mode) + (font-lock-ensure) + (should-not (face-at-point)) + (forward-char) + (should (equal (face-at-point) 'font-lock-type-face)) + (forward-line) + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (search-forward "som") + (should (equal (face-at-point) 'font-lock-string-face)))) + +(ert-deftest conf-test-desktop-mode () + ;; From `conf-desktop-mode' dostring. + (with-temp-buffer + (insert " [Desktop Entry] + Name=GNU Image Manipulation Program + Name[oc]=Editor d'imatge GIMP + Exec=gimp-2.8 %U + Terminal=false") + (goto-char (point-min)) + (conf-desktop-mode) + (font-lock-mode) + (font-lock-ensure) + (search-forward "Desk") + (should (equal (face-at-point) 'font-lock-type-face)) + (search-forward "Nam") + (should (equal (face-at-point) 'font-lock-variable-name-face)) + (forward-char 2) + (should-not (face-at-point)) + (search-forward "[") + (should (equal (face-at-point) 'font-lock-constant-face)))) + + + +(provide 'conf-mode-tests) + +;;; conf-mode-tests.el ends here commit cef2489379ee8d7d7752775abb70c367c301e6cf Author: Alex Branham Date: Sun Feb 10 14:32:29 2019 -0600 Use lexical binding for conf-mode * lisp/textmodes/conf-mode.el: Use lexical binding. (conf-align-assignments, conf-quote-normal, conf-mode-initialize): Doc fix. (Bug#34419) diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el index ad79ca4c26..ad9f60fabc 100644 --- a/lisp/textmodes/conf-mode.el +++ b/lisp/textmodes/conf-mode.el @@ -1,4 +1,4 @@ -;;; conf-mode.el --- Simple major mode for editing conf/ini/properties files +;;; conf-mode.el --- Simple major mode for editing conf/ini/properties files -*- lexical-binding: t; -*- ;; Copyright (C) 2004-2019 Free Software Foundation, Inc. @@ -281,10 +281,10 @@ whitespace.") ;; If anybody can figure out how to get the same effect by configuring ;; `align', I'd be glad to hear. (defun conf-align-assignments (&optional arg) - (interactive "P") "Align the assignments in the buffer or active region. In Transient Mark mode, if the mark is active, operate on the contents of the region. Otherwise, operate on the whole buffer." + (interactive "P") (setq arg (if arg (prefix-numeric-value arg) conf-assignment-column)) @@ -323,7 +323,7 @@ contents of the region. Otherwise, operate on the whole buffer." (defun conf-quote-normal (arg) "Set the syntax of \\=' and \" to punctuation. -With prefix arg, only do it for \\=' if 1, or only for \" if 2. +With prefix ARG, only do it for \\=' if 1, or only for \" if 2. This only affects the current buffer. Some conf files use quotes to delimit strings, while others allow quotes as simple parts of the assigned value. In those files font locking will be wrong, @@ -442,7 +442,7 @@ See also `conf-space-mode', `conf-colon-mode', `conf-javaprop-mode', (run-mode-hooks 'conf-mode-hook))) (defun conf-mode-initialize (comment &optional font-lock) - "Initializations for sub-modes of conf-mode. + "Initializations for sub-modes of `conf-mode'. COMMENT initializes `comment-start' and `comment-start-skip'. The optional arg FONT-LOCK is the value for FONT-LOCK-KEYWORDS." (set (make-local-variable 'comment-start) comment) commit b439b4393cbd0b98c14b72e791af7a5e4f8aced7 Author: Eli Zaretskii Date: Fri Feb 15 10:33:01 2019 +0200 Add documentation for last change in eww.el * doc/misc/eww.texi (Basics): Document the prefix arg effect on "M-x eww". (Bug#34374) * etc/NEWS: Mention the change in behavior of 'eww'. diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi index d7dc32846e..8dc58e8425 100644 --- a/doc/misc/eww.texi +++ b/doc/misc/eww.texi @@ -85,6 +85,10 @@ searched via @code{eww-search-prefix}. The default search engine is either prefix the file name with @code{file://} or use the command @kbd{M-x eww-open-file}. + If you invoke @code{eww} with a prefix argument, as in @w{@kbd{C-u +M-x eww}}, it will create a new EWW buffer instead of reusing the +default one, which is normally called @file{*eww*}. + @findex eww-quit @findex eww-reload @findex eww-copy-page-url diff --git a/etc/NEWS b/etc/NEWS index 73332a8a13..70a50c02c4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -660,6 +660,11 @@ and its value has been changed to Duck Duck Go. ** eww/shr ++++ +*** The 'eww' command can now create a new EWW buffer. +Invoking the command with a prefix argument will cause it to create a +new EWW buffer for the URL instead of reusing the default one. + +++ *** The 'd' ('eww-download') command now falls back to current page's URL. If this command is invoked with no URL at point, it now downloads the commit 3fa003a134471940956841cbcde9501767b765d6 Author: İ. Göktuğ Kayaalp Date: Sat Feb 9 17:41:31 2019 +0300 * lisp/net/eww.el (eww): With prefix arg, open url in new buffer. Bug#34374 diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 555b3bd591..d37a48126c 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -247,21 +247,29 @@ This list can be customized via `eww-suggest-uris'." (nreverse uris))) ;;;###autoload -(defun eww (url) +(defun eww (url &optional arg) "Fetch URL and render the page. If the input doesn't look like an URL or a domain name, the -word(s) will be searched for via `eww-search-prefix'." +word(s) will be searched for via `eww-search-prefix'. + +If called with a prefix ARG, use a new buffer instead of reusing +the default EWW buffer." (interactive (let* ((uris (eww-suggested-uris)) (prompt (concat "Enter URL or keywords" (if uris (format " (default %s)" (car uris)) "") ": "))) - (list (read-string prompt nil 'eww-prompt-history uris)))) + (list (read-string prompt nil 'eww-prompt-history uris) + (prefix-numeric-value current-prefix-arg)))) (setq url (eww--dwim-expand-url url)) (pop-to-buffer-same-window - (if (eq major-mode 'eww-mode) - (current-buffer) - (get-buffer-create "*eww*"))) + (cond + ((eq arg 4) + (generate-new-buffer "*eww*")) + ((eq major-mode 'eww-mode) + (current-buffer)) + (t + (get-buffer-create "*eww*")))) (eww-setup-buffer) ;; Check whether the domain only uses "Highly Restricted" Unicode ;; IDNA characters. If not, transform to punycode to indicate that commit 0d19e08da647c42562428dd608e5284cf414415e Author: João Távora Date: Thu Feb 14 23:33:49 2019 +0000 Change scoring strategy for 'flex' completion style The previous strategy had problems comparing scores of matches to strings of different lengths. This one seems slightly more sensible, and uses a new constant `flex-score-match-tightness' instead of the more abstract `flex-score-falloff'. It's not completely without problems, and I think it shouldn't count "holes" at the front and at the back, but that needs a different "pattern-to-regexp" conversion in completion-pcm--hilit-commonality. (defun test () (mapcar (lambda (a) (cons (substring-no-properties a) (get-text-property 0 'completion-score a))) (sort (completion-pcm--hilit-commonality '(prefix "f" star "o" star "o" point) '("foo" "barfoobaz" "foobarbaz" "barbazfoo" "fabrobazo" "foot" "foto" "fotttttttttttttttttttttttto")) (lambda (a b) (> (get-text-property 0 'completion-score a) (get-text-property 0 'completion-score b)))))) (let ((flex-score-match-tightness 100)) (test)) => (("foo" . 1.0) ("foot" . 0.375) ("foto" . 0.375) ("foobarbaz" . 0.16260162601626016) ;; one hole ("barbazfoo" . 0.16260162601626016) ;; one hole ("barfoobaz" . 0.10964912280701755) ;; two holes ("fabrobazo" . 0.10964912280701755) ;; two holes ("fotttttttttttttttttttttttto" . 0.04982561036372696)) (let ((flex-score-match-tightness 0.1)) (test)) => (("foo" . 1.0) ("foot" . 0.375) ("foto" . 0.375) ("barfoobaz" . 0.007751937984496124) ;; two holes ("fabrobazo" . 0.007751937984496124) ;; two holes ("foobarbaz" . 0.00641025641025641) ;; one hole ("barbazfoo" . 0.00641025641025641) ;; one hole ("fotttttttttttttttttttttttto" . 0.0004789272030651341)) * lisp/minibuffer.el (flex-score-falloff): Rename to flex-score-match-tightness. (completion-pcm--hilit-commonality): Update function. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index cdbd4b3b54..7413be42eb 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3042,21 +3042,16 @@ PATTERN is as returned by `completion-pcm--string->pattern'." (when (string-match-p regex c) (push c poss))) (nreverse poss)))))) -(defvar flex-score-falloff -1.5 +(defvar flex-score-match-tightness 100 "Controls how the `flex' completion style scores its matches. -Value is a number whose sign and amplitude have subtly different -effects. Positive values make the scoring formula value matches -scattered along the string, while negative values make the -formula value tighter matches. I.e \"foo\" matches both strings -\"barfoobaz\" and \"fabrobazo\", which are of equal length, but -only a negative value will score the former higher than the -second. - -The absolute value of this variable controls the relative order -of different-length strings matched by the same pattern . Its -effect is not completely understood yet, so feel free to play -around with it.") +Value is a positive number. Values smaller than one make the +scoring formula value matches scattered along the string, while +values greater than one make the formula value tighter matches. +I.e \"foo\" matches both strings \"barbazfoo\" and \"fabrobazo\", +which are of equal length, but only a value greater than one will +score the former (which has one \"hole\") higher than the +latter (which has two).") (defun completion-pcm--hilit-commonality (pattern completions) (when completions @@ -3092,10 +3087,10 @@ around with it.") ;; score 1. The formula takes the form of a quotient. ;; For the numerator, we use the number of +, i.e. the ;; length of the pattern. For the denominator, it - ;; counts the number of - in each such group, - ;; exponentiates that number to `flex-score-falloff', - ;; adds it to the total, adds one to the final sum, - ;; and then multiples by the length of the string. + ;; sums (1+ (/ (grouplen - 1) + ;; flex-score-match-tightness)) across all groups of + ;; -, sums one to that total, and then multiples by + ;; the length of the string. (score-numerator 0) (score-denominator 0) (last-b 0) @@ -3103,22 +3098,27 @@ around with it.") (lambda (a b) "Update score variables given match range (A B)." (setq - score-numerator (+ score-numerator (- b a)) - score-denominator (+ score-denominator - (expt (- a last-b) - flex-score-falloff)) + score-numerator (+ score-numerator (- b a))) + (unless (= a last-b) + (setq + score-denominator (+ score-denominator + 1 + (/ (- a last-b 1) + flex-score-match-tightness + 1.0)))) + (setq last-b b)))) - (funcall update-score 0 start) + (funcall update-score start start) (while md (funcall update-score start (car md)) (put-text-property start (pop md) 'font-lock-face 'completions-common-part str) (setq start (pop md))) + (funcall update-score len len) (put-text-property start end 'font-lock-face 'completions-common-part str) - (funcall update-score start end) (if (> (length str) pos) (put-text-property pos (1+ pos) 'font-lock-face 'completions-first-difference commit a4c7de35decaace94eba678161b0d4c8266647d2 Author: Mattias Engdegård Date: Thu Feb 14 16:09:55 2019 +0100 Add categories L, R, SPC and . to `rx' doc string * lisp/emacs-lisp/rx.el (rx): Add new categories to doc string. diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index c0a5d52788..b2299030a1 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -1056,7 +1056,9 @@ CHAR matches a character with category CATEGORY. CATEGORY must be either a character to use for C, or one of the following symbols. - `consonant' (\\c0 in string notation) + `space-for-indent' (\\c\\s in string notation) + `base' (\\c.) + `consonant' (\\c0) `base-vowel' (\\c1) `upper-diacritical-mark' (\\c2) `lower-diacritical-mark' (\\c3) @@ -1074,7 +1076,9 @@ CHAR `japanese-hiragana-two-byte' (\\cH) `indian-two-byte' (\\cI) `japanese-katakana-two-byte' (\\cK) + `strong-left-to-right' (\\cL) `korean-hangul-two-byte' (\\cN) + `strong-right-to-left' (\\cR) `cyrillic-two-byte' (\\cY) `combining-diacritic' (\\c^) `ascii' (\\ca) commit e2050920819aab658171e8c6af4a9e0ad322fcfa Author: Mattias Engdegård Date: Thu Feb 14 13:20:08 2019 +0100 Use lexical-binding in rx.el * lisp/emacs-lisp/rx.el: Use lexical-binding. (rx-form): Use `let' to bind the dynamic variable `rx-parent' instead of binding it as an argument. diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index d00b86819c..c0a5d52788 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -1,4 +1,4 @@ -;;; rx.el --- sexp notation for regular expressions +;;; rx.el --- sexp notation for regular expressions -*- lexical-binding: t -*- ;; Copyright (C) 2001-2019 Free Software Foundation, Inc. @@ -841,33 +841,34 @@ If FORM is `(minimal-match FORM1)', non-greedy versions of `*', (rx-group-if (cadr form) rx-parent)) -(defun rx-form (form &optional rx-parent) +(defun rx-form (form &optional parent) "Parse and produce code for regular expression FORM. FORM is a regular expression in sexp form. -RX-PARENT shows which type of expression calls and controls putting of +PARENT shows which type of expression calls and controls putting of shy groups around the result and some more in other functions." - (cond - ((stringp form) - (rx-group-if (regexp-quote form) - (if (and (eq rx-parent '*) (< 1 (length form))) - rx-parent))) - ((integerp form) - (regexp-quote (char-to-string form))) - ((symbolp form) - (let ((info (rx-info form nil))) - (cond ((stringp info) - info) - ((null info) - (error "Unknown rx form `%s'" form)) - (t - (funcall (nth 0 info) form))))) - ((consp form) - (let ((info (rx-info (car form) 'head))) - (unless (consp info) - (error "Unknown rx form `%s'" (car form))) - (funcall (nth 0 info) form))) - (t - (error "rx syntax error at `%s'" form)))) + (let ((rx-parent parent)) + (cond + ((stringp form) + (rx-group-if (regexp-quote form) + (if (and (eq parent '*) (< 1 (length form))) + parent))) + ((integerp form) + (regexp-quote (char-to-string form))) + ((symbolp form) + (let ((info (rx-info form nil))) + (cond ((stringp info) + info) + ((null info) + (error "Unknown rx form `%s'" form)) + (t + (funcall (nth 0 info) form))))) + ((consp form) + (let ((info (rx-info (car form) 'head))) + (unless (consp info) + (error "Unknown rx form `%s'" (car form))) + (funcall (nth 0 info) form))) + (t + (error "rx syntax error at `%s'" form))))) ;;;###autoload commit 959ba6ea79f1d348b0be294656d5b5a83371f4fb Author: João Távora Date: Thu Feb 14 13:46:07 2019 +0000 * lisp/minibuffer.el (completion-styles-alist): Tweak flex's docstring diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index daa8dba8c9..cdbd4b3b54 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -792,7 +792,7 @@ pattern \"*foo*bar*\".") completion-flex-try-completion completion-flex-all-completions "Completion of an in-order subset of characters. When completing \"foo\" the glob \"*f*o*o*\" is used, so that -i.e. foo can complete to frodo.") +\"foo\" can complete to \"frodo\".") (initials completion-initials-try-completion completion-initials-all-completions "Completion of acronyms and initialisms. commit ef718cbe9efde657903054d04cfc6aacb26d5100 Author: Michael Albinus Date: Thu Feb 14 12:36:18 2019 +0100 Adapt tramp-adb-handle-set-file-times * lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times): Use 'touch -d', 'touch -t' does not seem to work. Use Universal Time. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index f8b0505b41..22f2c5f6bf 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -679,8 +679,8 @@ But handle the case, if the \"test\" command is not available." (current-time) time))) (tramp-adb-send-command-and-check - v (format "touch -t %s %s" - (format-time-string "%Y%m%d%H%M.%S" time) + v (format "touch -d %s %s" + (format-time-string "%Y-%m-%dT%H:%M:%S" time t) (tramp-shell-quote-argument localname)))))) (defun tramp-adb-handle-copy-file commit fabfb54d1f60cf90e72b1efaabfbefbe877e076a Author: João Távora Date: Thu Feb 14 10:36:40 2019 +0000 ; * etc/NEWS (New 'flex' completion style): New entry diff --git a/etc/NEWS b/etc/NEWS index 1d79b05bc9..73332a8a13 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -266,6 +266,12 @@ When non-nil, 'switch-to-buffer' uses 'pop-to-buffer-same-window' that respects display actions specified by 'display-buffer-alist' and 'display-buffer-overriding-action'. +** New 'flex' completion style +An implementation of popular "flx/fuzzy/scatter" completion which +matches strings where the pattern appears as a subsequence. Put +simply, makes "foo" complete to both "barfoo" and "frodo". Add 'flex' +to 'completion-styles' or 'completion-category-overrides' to use it. + * Editing Changes in Emacs 27.1