commit 779bc886f9bc2e3188bf2577c3df2ae662ca1b98 (HEAD, refs/remotes/origin/master) Author: Dmitry Gutov Date: Fri May 15 08:10:22 2020 +0300 Improve detection of Git submodules * lisp/progmodes/project.el (project-try-vc): Improve detection of Git submodules (https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg02008.html). diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index ca8b5fa84e..eeff809e2a 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1,7 +1,7 @@ ;;; project.el --- Operations on the current project -*- lexical-binding: t; -*- ;; Copyright (C) 2015-2020 Free Software Foundation, Inc. -;; Version: 0.1 +;; Version: 0.1.1 ;; Package-Requires: ((emacs "26.3")) ;; This is a GNU ELPA :core package. Avoid using functionality that @@ -274,8 +274,23 @@ backend implementation of `project-external-roots'.") ('Git ;; Don't stop at submodule boundary. (or (vc-file-getprop dir 'project-git-root) - (vc-file-setprop dir 'project-git-root - (vc-find-root dir ".git/")))) + (let* ((default-directory dir) + (root (vc-root-dir))) + (vc-file-setprop + dir 'project-git-root + (cond + ((file-directory-p (expand-file-name ".git" root)) + root) + ((with-temp-buffer + (insert-file-contents ".git") + (goto-char (point-min)) + (looking-at "gitdir: [./]+/\.git/modules/")) + (let* ((parent (file-name-directory + (directory-file-name root))) + (default-directory parent)) + (vc-root-dir))) + (t root))) + ))) ('nil nil) (_ (ignore-errors (vc-call-backend backend 'root dir)))))) (and root (cons 'vc root)))) commit 065f6a1d8b5c7dc8f1bf758e22f2e9a7d17b47d4 Author: Tino Calancha Date: Thu May 14 22:02:09 2020 +0200 ; Fix warning in last change * lisp/arc-mode.el (archive--summarize-descs): Use file-modes-number-to-symbolic. diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 6ce64fe24b..6781c292d8 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -1506,7 +1506,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." (timelen (length (archive--file-desc-time sample))) (samplemode (and (archive--enabled-p 'Mode) (archive--file-desc-mode sample))) - (modelen (length (if samplemode (archive-int-to-mode samplemode))))) + (modelen (length (if samplemode (file-modes-number-to-symbolic samplemode))))) (dolist (desc descs) (when ids (let* ((uid (archive--file-desc-uid desc)) @@ -1553,7 +1553,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." (text (concat " " (when (> modelen 0) - (concat (archive-int-to-mode + (concat (file-modes-number-to-symbolic (archive--file-desc-mode desc)) " ")) (when ids commit 3a284e578625e617fdc6085ae11da2b4e41bb59b Author: Tino Calancha Date: Fri May 8 22:14:03 2020 +0200 Combine archive-int-to-mode and tar-grind-file-mode Add a new function, file-modes-number-to-symbolic. Make archive-int-to-mode and obsolete alias of it; use it to define tar-grind-file-mode (Bug#27952). * lisp/files.el (file-modes-number-to-symbolic): New defun. * lisp/arc-mode.el (archive-int-to-mode): Make it an obsolete alias. * lisp/tar-mode.el (tar-grind-file-mode): Use file-modes-number-to-symbolic. * test/lisp/arc-mode-tests.el (arc-mode-test-archive-int-to-mode) * test/lisp/tar-mode-tests.el (tar-mode-test-tar-grind-file-mode): Update test. * test/lisp/files-tests.el (files-tests-file-modes-symbolic-to-number) (files-tests-file-modes-number-to-symbolic): New tests. * doc/lispref/files.texi (Changing Files): Document the new funtion. * etc/NEWS (Lisp Changes in Emacs 28.1): Announce it. diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index b3ad9b9964..686dbdb1ca 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -1909,6 +1909,11 @@ omitted or @code{nil}, it defaults to 0, i.e., no access rights at all. @end defun +@defun file-modes-number-to-symbolic modes +This function converts a numeric file mode specification in +@var{modes} into the equivalent symbolic form. +@end defun + @defun set-file-times filename &optional time flag This function sets the access and modification times of @var{filename} to @var{time}. The return value is @code{t} if the times are successfully diff --git a/etc/NEWS b/etc/NEWS index ae676a9bf8..8a1d51c18d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -400,6 +400,10 @@ Use macro 'with-current-buffer-window' with action alist entry 'body-function'. * Lisp Changes in Emacs 28.1 ++++ +** New function 'file-modes-number-to-symbolic' to convert a numeric +file mode specification into symbolic form. + ** New macro 'dlet' to dynamically bind variables. ** The variable 'force-new-style-backquotes' has been removed. diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index c918f06c80..6ce64fe24b 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -563,28 +563,8 @@ in which case a second argument, length LEN, should be supplied." (aref str (- len i))))) result)) -(defun archive-int-to-mode (mode) - "Turn an integer like 0700 (i.e., 448) into a mode string like -rwx------." - ;; FIXME: merge with tar-grind-file-mode. - (if (null mode) - "??????????" - (string - (if (zerop (logand 8192 mode)) - (if (zerop (logand 16384 mode)) ?- ?d) - ?c) ; completeness - (if (zerop (logand 256 mode)) ?- ?r) - (if (zerop (logand 128 mode)) ?- ?w) - (if (zerop (logand 64 mode)) - (if (zerop (logand 2048 mode)) ?- ?S) - (if (zerop (logand 2048 mode)) ?x ?s)) - (if (zerop (logand 32 mode)) ?- ?r) - (if (zerop (logand 16 mode)) ?- ?w) - (if (zerop (logand 8 mode)) - (if (zerop (logand 1024 mode)) ?- ?S) - (if (zerop (logand 1024 mode)) ?x ?s)) - (if (zerop (logand 4 mode)) ?- ?r) - (if (zerop (logand 2 mode)) ?- ?w) - (if (zerop (logand 1 mode)) ?- ?x)))) +(define-obsolete-function-alias 'archive-int-to-mode + 'file-modes-number-to-symbolic "28.1") (defun archive-calc-mode (oldmode newmode) "From the integer OLDMODE and the string NEWMODE calculate a new file mode. diff --git a/lisp/files.el b/lisp/files.el index c34fe00388..dba704f7a4 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -7552,6 +7552,27 @@ as in \"og+rX-w\"." op char-right))) num-rights)) +(defun file-modes-number-to-symbolic (mode) + (string + (if (zerop (logand 8192 mode)) + (if (zerop (logand 16384 mode)) ?- ?d) + ?c) ; completeness + (if (zerop (logand 256 mode)) ?- ?r) + (if (zerop (logand 128 mode)) ?- ?w) + (if (zerop (logand 64 mode)) + (if (zerop (logand 2048 mode)) ?- ?S) + (if (zerop (logand 2048 mode)) ?x ?s)) + (if (zerop (logand 32 mode)) ?- ?r) + (if (zerop (logand 16 mode)) ?- ?w) + (if (zerop (logand 8 mode)) + (if (zerop (logand 1024 mode)) ?- ?S) + (if (zerop (logand 1024 mode)) ?x ?s)) + (if (zerop (logand 4 mode)) ?- ?r) + (if (zerop (logand 2 mode)) ?- ?w) + (if (zerop (logand 512 mode)) + (if (zerop (logand 1 mode)) ?- ?x) + (if (zerop (logand 1 mode)) ?T ?t)))) + (defun file-modes-symbolic-to-number (modes &optional from) "Convert symbolic file modes to numeric file modes. MODES is the string to convert, it should match diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index a3c1715b1e..73978ffc4a 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el @@ -480,23 +480,9 @@ checksum before doing the check." (defun tar-grind-file-mode (mode) "Construct a `rw-r--r--' string indicating MODE. -MODE should be an integer which is a file mode value." - (string - (if (zerop (logand 256 mode)) ?- ?r) - (if (zerop (logand 128 mode)) ?- ?w) - (if (zerop (logand 2048 mode)) - (if (zerop (logand 64 mode)) ?- ?x) - (if (zerop (logand 64 mode)) ?S ?s)) - (if (zerop (logand 32 mode)) ?- ?r) - (if (zerop (logand 16 mode)) ?- ?w) - (if (zerop (logand 1024 mode)) - (if (zerop (logand 8 mode)) ?- ?x) - (if (zerop (logand 8 mode)) ?S ?s)) - (if (zerop (logand 4 mode)) ?- ?r) - (if (zerop (logand 2 mode)) ?- ?w) - (if (zerop (logand 512 mode)) - (if (zerop (logand 1 mode)) ?- ?x) - (if (zerop (logand 1 mode)) ?T ?t)))) +MODE should be an integer which is a file mode value. +For instance, if mode is #o700, then it produces `rwx------'." + (substring (file-modes-number-to-symbolic mode) 1)) (defun tar-header-block-summarize (tar-hblock &optional mod-p) "Return a line similar to the output of `tar -vtf'." diff --git a/test/lisp/arc-mode-tests.el b/test/lisp/arc-mode-tests.el index df658b9813..22ca7e2ec5 100644 --- a/test/lisp/arc-mode-tests.el +++ b/test/lisp/arc-mode-tests.el @@ -28,7 +28,7 @@ (let ((alist (list (cons 448 "-rwx------") (cons 420 "-rw-r--r--") (cons 292 "-r--r--r--") - (cons 512 "----------") + (cons 512 "---------T") (cons 1024 "------S---") ; Bug#28092 (cons 2048 "---S------")))) (dolist (x alist) diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 05d9ceebf1..4b902fd82a 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1164,6 +1164,42 @@ works as expected if the default directory is quoted." (should-not (make-directory a/b t)) (delete-directory dir 'recursive))) +(ert-deftest files-tests-file-modes-symbolic-to-number () + (let ((alist (list (cons "a=rwx" #o777) + (cons "o=t" #o1000) + (cons "o=xt" #o1001) + (cons "o=tx" #o1001) ; Order doesn't matter. + (cons "u=rwx,g=rx,o=rx" #o755) + (cons "u=rwx,g=,o=" #o700) + (cons "u=rwx" #o700) ; Empty permissions can be ignored. + (cons "u=rw,g=r,o=r" #o644) + (cons "u=rw,g=r,o=t" #o1640) + (cons "u=rw,g=r,o=xt" #o1641) + (cons "u=rwxs,g=rs,o=xt" #o7741) + (cons "u=rws,g=rs,o=t" #o7640) + (cons "u=rws,g=rs,o=r" #o6644) + (cons "a=r" #o444) + (cons "u=S" nil) + (cons "u=T" nil) + (cons "u=Z" nil)))) + (dolist (x alist) + (if (cdr-safe x) + (should (equal (cdr x) (file-modes-symbolic-to-number (car x)))) + (should-error (file-modes-symbolic-to-number (car x))))))) + +(ert-deftest files-tests-file-modes-number-to-symbolic () + (let ((alist (list (cons #o755 "-rwxr-xr-x") + (cons #o700 "-rwx------") + (cons #o644 "-rw-r--r--") + (cons #o1640 "-rw-r----T") + (cons #o1641 "-rw-r----t") + (cons #o7741 "-rwsr-S--t") + (cons #o7640 "-rwSr-S--T") + (cons #o6644 "-rwSr-Sr--") + (cons #o444 "-r--r--r--")))) + (dolist (x alist) + (should (equal (cdr x) (file-modes-number-to-symbolic (car x))))))) + (ert-deftest files-tests-no-file-write-contents () "Test that `write-contents-functions' permits saving a file. Usually `basic-save-buffer' will prompt for a file name if the diff --git a/test/lisp/tar-mode-tests.el b/test/lisp/tar-mode-tests.el index bc41b863da..f05389df60 100644 --- a/test/lisp/tar-mode-tests.el +++ b/test/lisp/tar-mode-tests.el @@ -29,7 +29,8 @@ (cons 420 "rw-r--r--") (cons 292 "r--r--r--") (cons 512 "--------T") - (cons 1024 "-----S---")))) + (cons 1024 "-----S---") + (cons 2048 "--S------")))) (dolist (x alist) (should (equal (cdr x) (tar-grind-file-mode (car x))))))) commit 4af8b17149ee04655f038229c6103963f247ff87 Author: Mattias EngdegÄrd Date: Thu May 14 12:23:23 2020 +0200 Fix customisation of mouse-drag-and-drop-region (bug#41251) Reported by David Ponce. * lisp/mouse.el (mouse-drag-and-drop-region): Add missing unquote. diff --git a/lisp/mouse.el b/lisp/mouse.el index 9703d957d5..795b4da19e 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -2556,7 +2556,7 @@ region, text is copied instead of being cut." (lambda (modifier) `(const :tag ,(format "Enable, but copy with the %s modifier" modifier) - modifier)) + ,modifier)) '(alt super hyper shift control meta)) (other :tag "Enable dragging the region" t)) :version "26.1")