From ed05eaa9487b2c5a76a512532239a106e1cf9a2a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 21 Mar 2018 18:49:29 +0200 Subject: [PATCH 01/15] Improvements in dired.texi * doc/emacs/dired.texi (Dired): Mention that Dired works with remote directories. (Dired Enter): ls-lisp is used on some remote systems as well. (Dired Navigation): Mention and index the command names. (Dired Deletion): Document the 'always' value of dired-recursive-deletes. Mention the alternative deletion method. (Marks vs Flags): Fix spelling of Auto-Revert mode. Document what marking does on a subdirectory header line. (Operating on Files): Document that 'Z' uses gzip or compress. (Comparison in Dired): Mention ediff-files. (Misc Dired Features): Fix a typo. Suggested by Michael Albinus in emacs-manual-bugs@gnu.org. --- doc/emacs/dired.texi | 48 +++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index 309dfb32084..82882ab1b19 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi @@ -12,7 +12,8 @@ Dired makes an Emacs buffer containing a listing of a directory, and optionally some of its subdirectories as well. You can use the normal Emacs commands to move around in this buffer, and special Dired -commands to operate on the listed files. +commands to operate on the listed files. Dired works with both local +and remote directories. The Dired buffer is normally read-only, and inserting text in it is not allowed (however, the Wdired mode allows that, @pxref{Wdired}). @@ -109,8 +110,9 @@ default) means to perform the check; any other non-@code{nil} value means to use the @samp{--dired} option; and @code{nil} means not to use the @samp{--dired} option. - On MS-Windows and MS-DOS systems, Emacs emulates @command{ls}. -@xref{ls in Lisp}, for options and peculiarities of this emulation. + On MS-Windows and MS-DOS systems, and also on some remote systems, +Emacs emulates @command{ls}. @xref{ls in Lisp}, for options and +peculiarities of this emulation. @findex dired-other-window @kindex C-x 4 d @@ -131,10 +133,13 @@ deletes its window if the window was created just for that buffer. @kindex C-n @r{(Dired)} @kindex C-p @r{(Dired)} +@findex dired-next-line +@findex dired-previous-line All the usual Emacs cursor motion commands are available in Dired -buffers. The keys @kbd{C-n} and @kbd{C-p} are redefined to put the -cursor at the beginning of the file name on the line, rather than at -the beginning of the line. +buffers. The keys @kbd{C-n} and @kbd{C-p} are redefined to run +@code{dired-next-line} and @code{dired-previous-line}, respectively, +and they put the cursor at the beginning of the file name on the line, +rather than at the beginning of the line. @kindex SPC @r{(Dired)} For extra convenience, @key{SPC} and @kbd{n} in Dired are equivalent @@ -235,10 +240,11 @@ the buffer, and no files actually deleted. You can delete empty directories just like other files, but normally Dired cannot delete directories that are nonempty. If the variable @code{dired-recursive-deletes} is non-@code{nil}, then Dired can -delete nonempty directories including all their contents. That can -be somewhat risky. -Even if you have set @code{dired-recursive-deletes} to @code{nil}, -you might want sometimes to delete recursively directories +delete nonempty directories including all their contents. That can be +somewhat risky. If the value of the variable is @code{always}, Dired +will delete nonempty directories recursively, which is even more +risky. Even if you have set @code{dired-recursive-deletes} to +@code{nil}, you might want sometimes to delete recursively directories without being asked for confirmation for all of them. This is handy when you have marked many directories for deletion and you are very sure that all of them can safely be deleted. For every nonempty @@ -252,6 +258,9 @@ questions. directories into the operating system's Trash, instead of deleting them outright. @xref{Misc File Ops}. + An alternative way of deleting files is to mark them with @kbd{m} +and delete with @kbd{D}, see @ref{Operating on Files}. + @node Flagging Many Files @section Flagging Many Files at Once @cindex flagging many files for deletion (in Dired) @@ -420,7 +429,9 @@ Mark the current file with @samp{*} (@code{dired-mark}). If the region is active, mark all files in the region instead; otherwise, if a numeric argument @var{n} is supplied, mark the next @var{n} files instead, starting with the current file (if @var{n} is negative, mark -the previous @minus{}@var{n} files). +the previous @minus{}@var{n} files). If invoked on a subdirectory +header line (@pxref{Subdirectories in Dired}), this command marks all +the files in that subdirectory. @item * * @kindex * * @r{(Dired)} @@ -578,10 +589,10 @@ command will look in the buffer without revisiting the file, so the results might be inconsistent with the file on disk if its contents have changed since it was last visited. If you don't want this, you may wish to revert the files you have visited in your buffers, or to turn on -@code{auto-revert} mode in those buffers, before invoking this -command. @xref{Reverting}. If you prefer that this command should always +Auto-Revert mode in those buffers, before invoking this command. +@xref{Reverting}. If you prefer that this command should always revisit the file, without you having to revert the file or enable -@code{auto-revert} mode, you might want to set +Auto-Revert mode, you might want to set @code{dired-always-read-filesystem} to non-@code{nil}. @item C-/ @@ -755,7 +766,9 @@ suitable guess made using the variables @code{lpr-command} and @item Z Compress the specified files (@code{dired-do-compress}). If the file appears to be a compressed file already, uncompress it instead. Each -marked file is compressed into its own archive. +marked file is compressed into its own archive. This uses the +@command{gzip} program if it is available, otherwise it uses +@command{compress}. @findex dired-do-compress-to @kindex c @r{(Dired)} @@ -1037,6 +1050,9 @@ minibuffer is the file at the mark (i.e., the ordinary Emacs mark, not a Dired mark; @pxref{Setting Mark}). Otherwise, if the file at point has a backup file (@pxref{Backup}), that is the default. + You could also compare files using @code{ediff-files}, see +@ref{Major Entry Points,,, ediff, Ediff User's Manual}. + @node Subdirectories in Dired @section Subdirectories in Dired @cindex subdirectories in Dired @@ -1465,7 +1481,7 @@ space. each marked file. With just @kbd{C-u} as the prefix argument, it uses file names relative to the Dired buffer's default directory. (This can still contain slashes if in a subdirectory.) As a special case, -if point is on a directory headerline, @kbd{w} gives you the absolute +if point is on a directory header line, @kbd{w} gives you the absolute name of that directory. Any prefix argument or marked files are ignored in this case. From a5bf09900836dd6199c7630b88f8fdf9f2d89d7f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 21 Mar 2018 18:57:41 +0200 Subject: [PATCH 02/15] Improve documentation of Auto-Revert mode * doc/emacs/files.texi (Reverting): Mention that Aut-Revert applies to Dired buffers as well. Suggested by Michael Albinus in emacs-manual-bugs@gnu.org. --- doc/emacs/files.texi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index f1a7a65a800..1ced7ca07c6 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -988,6 +988,9 @@ Auto-Revert Tail mode works also for remote files. When a buffer is auto-reverted, a message is generated. This can be suppressed by setting @code{auto-revert-verbose} to @code{nil}. + In Dired buffers (@pxref{Dired}), Auto-Revert mode refreshes the +buffer when a file is created or deleted in the buffer's directory. + @xref{VC Undo}, for commands to revert to earlier versions of files under version control. @xref{VC Mode Line}, for Auto Revert peculiarities when visiting files under version control. From 4ab455147069d4b7247ba3aff0da3dba3a671df6 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Wed, 21 Mar 2018 17:36:34 +0000 Subject: [PATCH 03/15] Firm up documentation of generalized variables * doc/lispref/variables.texi (Generalized Variables) (Setting Generalized Variables): Define a generalized variable as something setf can write to. Remove the insinuation that hackers have poor memories. State explicitly that the list of GVs given is complete. Remove the suggestion that `setf' has superseded, or is in the process of superseding, `setq'. Make minor corrections to the English. --- doc/lispref/variables.texi | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index aecee6f3056..b80bc88a585 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -2317,11 +2317,12 @@ Attempting to assign them any other value will result in an error: @cindex generalized variable @cindex place form -A @dfn{generalized variable} or @dfn{place form} is one of the many places -in Lisp memory where values can be stored. The simplest place form is -a regular Lisp variable. But the @sc{car}s and @sc{cdr}s of lists, elements -of arrays, properties of symbols, and many other locations are also -places where Lisp values are stored. +A @dfn{generalized variable} or @dfn{place form} is one of the many +places in Lisp memory where values can be stored using the @code{setf} +macro (@pxref{Setting Generalized Variables}). The simplest place +form is a regular Lisp variable. But the @sc{car}s and @sc{cdr}s of +lists, elements of arrays, properties of symbols, and many other +locations are also places where Lisp values get stored. Generalized variables are analogous to lvalues in the C language, where @samp{x = a[i]} gets an element from an array @@ -2342,8 +2343,8 @@ variables. The @code{setf} form is like @code{setq}, except that it accepts arbitrary place forms on the left side rather than just symbols. For example, @code{(setf (car a) b)} sets the car of @code{a} to @code{b}, doing the same operation as @code{(setcar a b)}, -but without having to remember two separate functions for setting and -accessing every type of place. +but without you having to use two separate functions for setting and +accessing this type of place. @defmac setf [place form]@dots{} This macro evaluates @var{form} and stores it in @var{place}, which @@ -2353,18 +2354,19 @@ just as with @code{setq}. @code{setf} returns the value of the last @var{form}. @end defmac -The following Lisp forms will work as generalized variables, and -so may appear in the @var{place} argument of @code{setf}: +The following Lisp forms are the forms in Emacs that will work as +generalized variables, and so may appear in the @var{place} argument +of @code{setf}: @itemize @item -A symbol naming a variable. In other words, @code{(setf x y)} is -exactly equivalent to @code{(setq x y)}, and @code{setq} itself is -strictly speaking redundant given that @code{setf} exists. Many -programmers continue to prefer @code{setq} for setting simple -variables, though, purely for stylistic or historical reasons. -The macro @code{(setf x y)} actually expands to @code{(setq x y)}, -so there is no performance penalty for using it in compiled code. +A symbol. In other words, @code{(setf x y)} is exactly equivalent to +@code{(setq x y)}, and @code{setq} itself is strictly speaking +redundant given that @code{setf} exists. Most programmers will +continue to prefer @code{setq} for setting simple variables, though, +for stylistic and historical reasons. The macro @code{(setf x y)} +actually expands to @code{(setq x y)}, so there is no performance +penalty for using it in compiled code. @item A call to any of the following standard Lisp functions: From 143b485029f8d438001aa6e989954a92c4b2a60b Mon Sep 17 00:00:00 2001 From: "Charles A. Roelli" Date: Wed, 21 Mar 2018 20:52:35 +0100 Subject: [PATCH 04/15] * doc/lispref/internals.texi (Writing Emacs Primitives): Fix grammar. --- doc/lispref/internals.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 8bf9abfc614..6d25eb14dfd 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -843,7 +843,7 @@ defined with @code{DEFVAR_BOOL} are automatically added to the list @code{byte-boolean-vars} used by the byte compiler. @cindex defining customization variables in C - If you want to make a Lisp variables that is defined in C behave + If you want to make a Lisp variable that is defined in C behave like one declared with @code{defcustom}, add an appropriate entry to @file{cus-start.el}. From 5268f3059db7638caa6d387d35e27870fbcb976c Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 21 Mar 2018 16:58:11 -0400 Subject: [PATCH 05/15] * doc/lispref/windows.texi (Selecting Windows): Fix a typo. --- doc/lispref/windows.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 75651b99fde..8d8877bdfda 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -1772,7 +1772,7 @@ raise the frame or make sure input focus is directed to that frame. @end defun @cindex select window hook -@cindex running a hook when a windows gets selected +@cindex running a hook when a window gets selected For historical reasons, Emacs does not run a separate hook whenever a window gets selected. Applications and internal routines often temporarily select a window to perform a few actions on it. They do From e32f3525ea3aabad0801874b24869b181535c104 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 21 Mar 2018 19:38:44 -0400 Subject: [PATCH 06/15] * lisp/ibuf-ext.el (ibuffer-never-search-content-mode): Fix type. --- lisp/ibuf-ext.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 2023165b2a6..a3143e5e29a 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -114,7 +114,7 @@ Buffers whose name matches a regexp in this list, are not searched." "A list of major modes ignored by `ibuffer-mark-by-content-regexp'. Buffers whose major mode is in this list, are not searched." :version "26.1" - :type '(repeat regexp) + :type '(repeat (symbol :tag "Major mode")) :require 'ibuf-ext :group 'ibuffer) From 47917d8f4dbb711435fe46765fd0290e1f4a16b3 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 21 Mar 2018 20:47:28 -0400 Subject: [PATCH 07/15] * lisp/gnus/gnus-cloud.el (gnus-cloud-synced-files): Fix doc & type. --- lisp/gnus/gnus-cloud.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lisp/gnus/gnus-cloud.el b/lisp/gnus/gnus-cloud.el index 284fdca494e..d5970f31265 100644 --- a/lisp/gnus/gnus-cloud.el +++ b/lisp/gnus/gnus-cloud.el @@ -48,10 +48,14 @@ "~/.authinfo.gpg" "~/.gnus.el" (:directory "~/News" :match ".*.SCORE\\'")) - "List of file regexps that should be kept up-to-date via the cloud." + "List of files that should be kept up-to-date via the cloud. +Each element may be either a string or a property list. +The latter should have a :directory element whose value is a string, +and a :match element whose value is a regular expression to match +against the basename of files in said directory." :group 'gnus-cloud - ;; FIXME this type does not match the default. Nor does the documentation. - :type '(repeat regexp)) + :type '(repeat (choice (string :tag "File") + (plist :tag "Property list")))) (defcustom gnus-cloud-storage-method (if (featurep 'epg) 'epg 'base64-gzip) "Storage method for cloud data, defaults to EPG if that's available." @@ -290,6 +294,8 @@ Use old data if FORCE-OLDER is not nil." (dolist (elem gnus-cloud-synced-files) (cond ((stringp elem) + ;; This seems fragile. String comparison, with no + ;; expand-file-name to resolve ~, etc. (when (equal elem file-name) (setq matched t))) ((consp elem) From 4ec935dc5bc5d6e6ad5c9eb8027412b333b4b9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= Date: Fri, 15 Dec 2017 21:42:21 +0100 Subject: [PATCH 08/15] Add new tests for eieio persistence * test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el: (hash-equal): New comparison test for hash-tables. (persist-test-save-and-compare): Use test for hash-tables. (eieio-test-persist-hash-and-vector, eieio-test-persist-interior-lists): New tests. --- .../eieio-tests/eieio-test-persist.el | 113 ++++++++++++++++-- 1 file changed, 103 insertions(+), 10 deletions(-) diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el index a3ab3834899..ff4aaf7aeb8 100644 --- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el +++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el @@ -1,4 +1,4 @@ -;;; eieio-persist.el --- Tests for eieio-persistent class +;;; eieio-test-persist.el --- Tests for eieio-persistent class ;; Copyright (C) 2011-2018 Free Software Foundation, Inc. @@ -40,6 +40,17 @@ This is usually a symbol that starts with `:'." (car tuple) nil))) +(defun hash-equal (hash1 hash2) + "Compare two hash tables to see whether they are equal." + (and (= (hash-table-count hash1) + (hash-table-count hash2)) + (catch 'flag + (maphash (lambda (x y) + (or (equal (gethash x hash2) y) + (throw 'flag nil))) + hash1) + (throw 'flag t)))) + (defun persist-test-save-and-compare (original) "Compare the object ORIGINAL against the one read fromdisk." @@ -49,8 +60,8 @@ This is usually a symbol that starts with `:'." (class (eieio-object-class original)) (fromdisk (eieio-persistent-read file class)) (cv (cl--find-class class)) - (slots (eieio--class-slots cv)) - ) + (slots (eieio--class-slots cv))) + (unless (object-of-class-p fromdisk class) (error "Persistent class %S != original class %S" (eieio-object-class fromdisk) @@ -62,18 +73,24 @@ This is usually a symbol that starts with `:'." (origvalue (eieio-oref original oneslot)) (fromdiskvalue (eieio-oref fromdisk oneslot)) (initarg-p (eieio--attribute-to-initarg - (cl--find-class class) oneslot)) - ) + (cl--find-class class) oneslot))) (if initarg-p - (unless (equal origvalue fromdiskvalue) + (unless + (cond ((and (hash-table-p origvalue) (hash-table-p fromdiskvalue)) + (hash-equal origvalue fromdiskvalue)) + (t (equal origvalue fromdiskvalue))) (error "Slot %S Original Val %S != Persistent Val %S" oneslot origvalue fromdiskvalue)) ;; Else !initarg-p - (unless (equal (cl--slot-descriptor-initform slot) fromdiskvalue) + (let ((origval (cl--slot-descriptor-initform slot)) + (diskval fromdiskvalue)) + (unless + (cond ((and (hash-table-p origval) (hash-table-p diskval)) + (hash-equal origval diskval)) + (t (equal origval diskval))) (error "Slot %S Persistent Val %S != Default Value %S" - oneslot fromdiskvalue (cl--slot-descriptor-initform slot)))) - )))) + oneslot diskval origvalue)))))))) ;;; Simple Case ;; @@ -205,13 +222,16 @@ persistent class.") ((slot1 :initarg :slot1 :type (or persistent-random-class null persist-not-persistent)) (slot2 :initarg :slot2 - :type (or persist-not-persistent persist-random-class null)))) + :type (or persist-not-persistent persistent-random-class null)) + (slot3 :initarg :slot3 + :type persistent-random-class))) (ert-deftest eieio-test-multiple-class-slot () (let ((persist (persistent-multiclass-slot "random string" :slot1 (persistent-random-class) :slot2 (persist-not-persistent) + :slot3 (persistent-random-class) :file (concat default-directory "test-ps5.pt")))) (unwind-protect (persist-test-save-and-compare persist) @@ -238,4 +258,77 @@ persistent class.") (persist-test-save-and-compare persist-wols) (delete-file (oref persist-wols file)))) +;;; Tests targeted at popular libraries in the wild. + +;; Objects inside hash tables and vectors (pcache), see bug#29220. +(defclass person () + ((name :type string :initarg :name))) + +(defclass classy (eieio-persistent) + ((teacher + :type person + :initarg :teacher) + (students + :initarg :students :initform (make-hash-table :test 'equal)) + (janitors + :type list + :initarg :janitors) + (random-vector + :type vector + :initarg :random-vector))) + +(ert-deftest eieio-test-persist-hash-and-vector () + (let* ((jane (make-instance 'person :name "Jane")) + (bob (make-instance 'person :name "Bob")) + (hans (make-instance 'person :name "Hans")) + (dierdre (make-instance 'person :name "Dierdre")) + (class (make-instance 'classy + :teacher jane + :janitors (list [tuesday nil] + [friday nil]) + :random-vector [nil] + :file (concat default-directory "classy-" emacs-version ".eieio")))) + (puthash "Bob" bob (slot-value class 'students)) + (aset (slot-value class 'random-vector) 0 + (make-instance 'persistent-random-class)) + (aset (car (slot-value class 'janitor)) 1 hans) + (aset (nth 1 (slot-value class 'janitor)) 1 dierdre) + (unwind-protect + (persist-test-save-and-compare class) + (delete-file (oref class file))))) + +;; Extra quotation of lists inside other objects (Gnus registry), also +;; bug#29220. + +(defclass eieio-container (eieio-persistent) + ((alist + :initarg :alist + :type list) + (vec + :initarg :vec + :type vector) + (htab + :initarg :htab + :type hash-table))) + +(ert-deftest eieio-test-persist-interior-lists () + (let* ((thing (make-instance + 'eieio-container + :vec [nil] + :htab (make-hash-table :test #'equal) + :file (concat default-directory + "container-" emacs-version ".eieio"))) + (john (make-instance 'person :name "John")) + (alexie (make-instance 'person :name "Alexie")) + (alst '(("first" (one two three)) + ("second" (four five six))))) + (setf (nth 2 (cadar alst)) john + (nth 2 (cadadr alst)) alexie) + (setf (slot-value thing 'alist) alst) + (puthash "alst" alst (slot-value thing 'htab)) + (aset (slot-value thing 'vec) 0 alst) + (unwind-protect + (persist-test-save-and-compare thing) + (delete-file (slot-value thing 'file))))) + ;;; eieio-test-persist.el ends here From 40ad1ff327616721ce060ea774631b54e3ba26ca Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Tue, 19 Dec 2017 14:56:13 -0800 Subject: [PATCH 09/15] Handle possible classtype values in eieio-persistent-read * lisp/emacs-lisp/eieio-base.el (eieio-persistent-validate/fix-slot-value): The function `eieio-persistent-slot-type-is-class-p' could return either a single class, or a list of classes. --- lisp/emacs-lisp/eieio-base.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index f0fed17b7da..af240794e38 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el @@ -349,7 +349,7 @@ Second, any text properties will be stripped from strings." (seq-some (lambda (elt) (child-of-class-p (car proposed-value) elt)) - classtype)) + (if (listp classtype) classtype (list classtype)))) (eieio-persistent-convert-list-to-object proposed-value)) (t From f0cf4dc62918a5acd2c6bbade78909cfa73ca9c8 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Thu, 28 Dec 2017 18:14:47 -0800 Subject: [PATCH 10/15] Let eieio-persistent-read read what object-write has written * lisp/emacs-lisp/eieio-base.el (eieio-persistent-validate/fix-slot-value): `object-write' may quote lists inside hash tables and vectors, so unquote those lists here. This patch allows the eieio-persistent write/restore process to perform a clean round trip. It only handles a very specific and limited range of object structures, but at least the write and read procedures match. --- lisp/emacs-lisp/eieio-base.el | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index af240794e38..5ff8574d9a9 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el @@ -360,19 +360,28 @@ Second, any text properties will be stripped from strings." ((hash-table-p proposed-value) (maphash (lambda (key value) - (when (class-p (car-safe value)) - (setf (gethash key proposed-value) - (eieio-persistent-convert-list-to-object - value)))) + (cond ((class-p (car-safe value)) + (setf (gethash key proposed-value) + (eieio-persistent-convert-list-to-object + value))) + ((and (consp value) + (eq (car value) 'quote)) + (setf (gethash key proposed-value) + (cadr value))))) proposed-value) proposed-value) ((vectorp proposed-value) (dotimes (i (length proposed-value)) - (when (class-p (car-safe (aref proposed-value i))) - (aset proposed-value i - (eieio-persistent-convert-list-to-object - (aref proposed-value i))))) + (let ((val (aref proposed-value i))) + (cond ((class-p (car-safe val)) + (aset proposed-value i + (eieio-persistent-convert-list-to-object + (aref proposed-value i)))) + ((and (consp val) + (eq (car val) 'quote)) + (aset proposed-value i + (cadr val)))))) proposed-value) ((stringp proposed-value) From 7612dd14b60317b0d216112acdc169724aa0b464 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sat, 30 Dec 2017 10:12:22 -0800 Subject: [PATCH 11/15] Adjust eieio persistence tests for expected failure * test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el (eieio-test-persist-hash-and-vector, eieio-test-persist-interior-lists): Persistence does not currently handle deeply-nested objects. Expect current failures, and mark for future fixes. --- .../emacs-lisp/eieio-tests/eieio-test-persist.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el index ff4aaf7aeb8..eae69c89eb2 100644 --- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el +++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el @@ -291,10 +291,14 @@ persistent class.") (puthash "Bob" bob (slot-value class 'students)) (aset (slot-value class 'random-vector) 0 (make-instance 'persistent-random-class)) - (aset (car (slot-value class 'janitor)) 1 hans) - (aset (nth 1 (slot-value class 'janitor)) 1 dierdre) (unwind-protect (persist-test-save-and-compare class) + (delete-file (oref class file))) + (aset (car (slot-value class 'janitors)) 1 hans) + (aset (nth 1 (slot-value class 'janitors)) 1 dierdre) + (unwind-protect + ;; FIXME: This should not error. + (should-error (persist-test-save-and-compare class)) (delete-file (oref class file))))) ;; Extra quotation of lists inside other objects (Gnus registry), also @@ -322,13 +326,17 @@ persistent class.") (alexie (make-instance 'person :name "Alexie")) (alst '(("first" (one two three)) ("second" (four five six))))) - (setf (nth 2 (cadar alst)) john - (nth 2 (cadadr alst)) alexie) (setf (slot-value thing 'alist) alst) (puthash "alst" alst (slot-value thing 'htab)) (aset (slot-value thing 'vec) 0 alst) (unwind-protect (persist-test-save-and-compare thing) + (delete-file (slot-value thing 'file))) + (setf (nth 2 (cadar alst)) john + (nth 2 (cadadr alst)) alexie) + (unwind-protect + ;; FIXME: Should not error. + (should-error (persist-test-save-and-compare thing)) (delete-file (slot-value thing 'file))))) ;;; eieio-test-persist.el ends here From daa9e853bd6de90e0fc0b13e30eb261c5a45774e Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sat, 10 Mar 2018 16:26:38 +0800 Subject: [PATCH 12/15] Improve warning and error messages * lisp/emacs-lisp/eieio-base.el (eieio-persistent-read, (eieio-persistent-validate/fix-slot-value): Indicate exactly what went wrong. --- lisp/emacs-lisp/eieio-base.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 5ff8574d9a9..cba6cab1d4f 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el @@ -219,7 +219,7 @@ for CLASS. Optional ALLOW-SUBCLASS says that it is ok for `eieio-persistent-read' to load in subclasses of class instead of being pedantic." (unless class - (message "Unsafe call to `eieio-persistent-read'.")) + (warn "`eieio-persistent-read' called without specifying a class")) (when class (cl-check-type class class)) (let ((ret nil) (buffstr nil)) @@ -234,13 +234,16 @@ being pedantic." ;; the current buffer will work. (setq ret (read buffstr)) (when (not (child-of-class-p (car ret) 'eieio-persistent)) - (error "Corrupt object on disk: Unknown saved object")) + (error + "Invalid object: %s is not a subclass of `eieio-persistent'" + (car ret))) (when (and class - (not (or (eq (car ret) class ) ; same class - (and allow-subclass - (child-of-class-p (car ret) class)) ; subclasses - ))) - (error "Corrupt object on disk: Invalid saved class")) + (not (or (eq (car ret) class) ; same class + (and allow-subclass ; subclass + (child-of-class-p (car ret) class))))) + (error + "Invalid object: %s is not an object of class %s nor a subclass" + (car ret) class)) (setq ret (eieio-persistent-convert-list-to-object ret)) (oset ret file filename)) (kill-buffer " *tmp eieio read*")) @@ -332,7 +335,8 @@ Second, any text properties will be stripped from strings." ;; We have a predicate, but it doesn't satisfy the predicate? (dolist (PV (cdr proposed-value)) (unless (child-of-class-p (car PV) (car classtype)) - (error "Corrupt object on disk"))) + (error "Invalid object: slot member %s does not match class %s" + (car PV) (car classtype)))) ;; We have a list of objects here. Lets load them ;; in. From cc1702f790443cac70f93661d2a5552caf986769 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 22 Mar 2018 11:15:23 +0200 Subject: [PATCH 13/15] Fix the MSDOS build * msdos/sed2v2.inp (HAVE_SBRK): Define to 1. --- msdos/sed2v2.inp | 1 + 1 file changed, 1 insertion(+) diff --git a/msdos/sed2v2.inp b/msdos/sed2v2.inp index d18242eac30..ea75356f992 100644 --- a/msdos/sed2v2.inp +++ b/msdos/sed2v2.inp @@ -32,6 +32,7 @@ /^#undef DOS_NT *$/s/^.*$/#define DOS_NT/ /^#undef FLOAT_CHECK_DOMAIN *$/s/^.*$/#define FLOAT_CHECK_DOMAIN/ /^#undef HAVE_ALLOCA *$/s/^.*$/#define HAVE_ALLOCA 1/ +/^#undef HAVE_SBRK *$/s/^.*$/#define HAVE_SBRK 1/ /^#undef HAVE_SETITIMER *$/s/^.*$/#define HAVE_SETITIMER 1/ /^#undef HAVE_STRUCT_UTIMBUF *$/s/^.*$/#define HAVE_STRUCT_UTIMBUF 1/ /^#undef LOCALTIME_CACHE *$/s/^.*$/#define LOCALTIME_CACHE 1/ From 16d0cc73f2bc11777eb2884594b0832abd5f30a4 Mon Sep 17 00:00:00 2001 From: Nicolas Petton Date: Thu, 22 Mar 2018 11:55:15 +0100 Subject: [PATCH 14/15] * etc/NEWS: Add an entry for auth-source-pass. --- etc/NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index eded00e6554..f5da6870b77 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1274,6 +1274,10 @@ specialized for editing freedesktop.org desktop entries. ** New major mode 'less-css-mode' (a minor variant of 'css-mode') for editing Less files. ++++ +** New package 'auth-source-pass' integrates 'auth-source' with the +password manager password-store (http://passwordstore.org). + * Incompatible Lisp Changes in Emacs 26.1 From 8ac621bb5594786c66cc724864e6037c8c650774 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 22 Mar 2018 14:57:43 +0200 Subject: [PATCH 15/15] Document DEFUN attributes * doc/lispref/internals.texi (Writing Emacs Primitives): Document specification of function attributes in DEFUN. --- doc/lispref/internals.texi | 39 +++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 6d25eb14dfd..398ea8de855 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -735,7 +735,7 @@ Lisp form. For example: @example @group -DEFUN ("foo", Ffoo, Sfoo, 0, UNEVALLED, +DEFUN ("foo", Ffoo, Sfoo, 0, UNEVALLED, 0 "(list (read-char-by-name \"Insert character: \")\ (prefix-numeric-value current-prefix-arg)\ t))", @@ -761,6 +761,43 @@ arguments. All the usual rules for documentation strings in Lisp code (@pxref{Documentation Tips}) apply to C code documentation strings too. + +The documentation string can be followed by a list of C function +attributes for the C function that implements the primitive, like +this: + +@example +@group +DEFUN ("bar", Fbar, Sbar, 0, UNEVALLED, 0 + doc: /* @dots{} /* + attributes: @var{attr1} @var{attr2} @dots{}) +@end group +@end example + +@noindent +You can specify more than a single attribute, one after the other. +Currently, only the following attributes are recognized: + +@table @code +@item noreturn +Declares the C function as one that never returns. This corresponds +to the C11 keyword @code{_Noreturn} and to @w{@code{__attribute__ +((__noreturn__))}} attribute of GCC (@pxref{Function Attributes,,, +gcc, Using the GNU Compiler Collection}). + +@item const +Declares that the function does not examine any values except its +arguments, and has no effects except the return value. This +corresponds to @w{@code{__attribute__ ((__const__))}} attribute of +GCC. + +@item noinline +This corresponds to @w{@code{__attribute__ ((__noinline__))}} +attribute of GCC, which prevents the function from being considered +for inlining. This might be needed, e.g., to countermand effects of +link-time optimizations on stack-based variables. +@end table + @end table After the call to the @code{DEFUN} macro, you must write the