commit 83968cbeee06cc0fff932d5052e431b478276841 (HEAD, refs/remotes/origin/master) Author: Stefan Monnier Date: Mon Nov 25 10:13:38 2024 -0500 (undo-delta): Handle `apply` elements (bug#74523) * lisp/simple.el (undo-delta): Handle `apply` elements. * test/lisp/simple-tests.el (simple-tests--undo-apply): New test. (simple-tests--undo-equiv-table): Adjust test so it's not influenced by previous operation. diff --git a/lisp/simple.el b/lisp/simple.el index dde6be4d78a..1ad7f7282f3 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3993,6 +3993,9 @@ with < or <= based on USE-<." ((integerp (car undo-elt)) ;; (BEGIN . END) (cons (car undo-elt) (- (car undo-elt) (cdr undo-elt)))) + ;; (apply DELTA BEG END FUNC . ARGS) + ((and (eq (car undo-elt) 'apply) (integerp (nth 1 undo-elt))) + (cons (nth 2 undo-elt) (nth 1 undo-elt))) (t '(0 . 0))) '(0 . 0))) diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index d94fa4a583d..69ea6b98144 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el @@ -571,6 +571,51 @@ See bug#35036." (simple-tests--exec '(undo-redo)) (should (equal (buffer-string) "abcde")))) +(ert-deftest simple-tests--undo-apply () ;bug#74523 + (with-temp-buffer + (modula-2-mode) ;; A simple mode with non-LF terminated comments. + (buffer-enable-undo) + (insert "foo\n\n") + (let ((midbeg (point-marker)) + (_ (insert "midmid")) + (midend (point-marker))) + (insert "\n\nbar") + (undo-boundary) + (goto-char (+ midbeg 3)) + (insert "\n") + (undo-boundary) + (comment-region (point-min) midbeg) ;inserts an `apply' element. + (undo-boundary) + (comment-region midend (point-max)) ;inserts an `apply' element. + (undo-boundary) + (progn + (goto-char midbeg) + (set-mark midend) + (setq last-command 'something-else) ;Not `undo', so we start a new run. + (undo '(4)) + (should (equal (buffer-substring midbeg midend) "midmid"))) + ;; (progn + ;; (goto-char (point-min)) + ;; ;; FIXME: `comment-region-default' puts a too conservative boundary + ;; ;; on the `apply' block, so we have to use a larger undo-region to + ;; ;; include the comment-region action. This in turn makes the + ;; ;; undo-region include the \n insertion/deletion so we need 2 undo + ;; ;; steps. + ;; (set-mark (1+ midend)) + ;; (setq last-command 'something-else) ;Not `undo', so we start a new run. + ;; (undo '(4)) + ;; (setq last-command 'undo) ;Continue the undo run. + ;; (undo) + ;; (should (equal (buffer-substring (point-min) midbeg) "foo\n\n"))) + ;; (progn + ;; (goto-char (point-max)) + ;; (set-mark midend) + ;; (setq last-command 'something-else) ;Not `undo', so we start a new run. + ;; (undo '(4)) + ;; (should (equal (buffer-substring midend (point-max)) "\n\nbar")) + ;; (should (equal (buffer-string) "foo\n\nmidmid\n\nbar"))) + ))) + (defun simple-tests--sans-leading-nil (lst) "Return LST sans the leading nils." (while (and (consp lst) (null (car lst))) @@ -589,7 +634,8 @@ See bug#35036." (undo-boundary)) (should (equal (buffer-string) "abc")) ;; Tests mappings in `undo-equiv-table'. - (simple-tests--exec '(undo)) + ;; `ignore' makes sure the `undo' won't continue a previous `undo'. + (simple-tests--exec '(ignore undo)) (should (equal (buffer-string) "ab")) (should (eq (gethash (simple-tests--sans-leading-nil buffer-undo-list) commit 0d466151109f41e84ec4183ba47d88dba1eb360c Author: Michael Albinus Date: Mon Nov 25 11:29:40 2024 +0100 Extend Tramp FAQ * doc/misc/tramp.texi (Frequently Asked Questions): Improve index. Recommend `small-temporary-file-directory' for ssh sockets. diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 8098366dc09..ca2cb0d1e91 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -5770,6 +5770,7 @@ connection-local value. @end group @end lisp +@vindex XDG_DATA_HOME@r{, environment variable} If Emacs is configured to use the XDG conventions for the trash directory, remote files cannot be restored with the respective tools, because those conventions don't specify remote paths. Such files must @@ -6203,6 +6204,36 @@ as above in your @file{~/.emacs}: @end lisp +@item +I get an error @samp{unix_listener: path +"/very/long/path/.cache/emacs/tramp.XXX" too long for Unix domain +socket} when connectiong via @option{ssh} to a remote host. + +@vindex small-temporary-file-directory +By default, @value{tramp} uses the directory @file{~/.cache/emacs/} +for creation of OpenSSH Unix domain sockets. On GNU/Linux, domain +sockets have a much lower maximum path length (currently 107 +characters) than normal files. + +You can change this directory by setting the user option +@code{small-temporary-file-directory} to another name, like + +@lisp +@group +(unless small-temporary-file-directory + (customize-set-variable + 'small-temporary-file-directory + (format "/run/user/%d/emacs/" (user-uid))) + (make-directory small-temporary-file-directory t)) +@end group +@end lisp + +@vindex XDG_RUNTIME_DIR@r{, environment variable} +@t{"/run/user/UID"} is the value of the environment variable +@env{XDG_RUNTIME_DIR}, which you can use instead via @code{(getenv +"XDG_RUNTIME_DIR")}. + + @item How to ignore errors when changing file attributes?