GNU bug report logs -
#33871
27.0.50; Revert Dired window saved in window configuration
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Tue, 25 Dec 2018 21:43:01 UTC
Severity: minor
Found in version 27.0.50
Fixed in version 30.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
>> (setq-default window-use-context-function
>> (lambda (w context)
>> (let ((point (window-point w)))
>> (with-current-buffer (window-buffer w)
>
> I suppose that in the general case you need a
>
> (save-excursion
Thanks. I just noticed this is broken in two windows case,
and your suggestion fixed it.
> Probably something similar is needed for dired, for example to handle
> the case where its buffer is simultaneously shown in two windows with
> their points on different lines.
So here is the same for dired:
diff --git a/lisp/dired.el b/lisp/dired.el
index 9e3b888df14..0510db1c409 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2743,6 +2745,26 @@ dired-mode
'(dired-font-lock-keywords t nil nil beginning-of-line))
(setq-local desktop-save-buffer 'dired-desktop-buffer-misc-data)
(setq-local grep-read-files-function #'dired-grep-read-files)
+ (setq-local window-set-context-function
+ (lambda (w)
+ (let ((point (window-point w)))
+ (with-current-buffer (window-buffer w)
+ (save-excursion
+ (goto-char point)
+ (if-let ((f (dired-get-filename nil t)))
+ `((dired-filename . ,f))
+ `((position . ,(point)))))))))
+ (setq-local window-use-context-function
+ (lambda (w context)
+ (let ((point (window-point w)))
+ (with-current-buffer (window-buffer w)
+ (save-excursion
+ (if-let ((f (alist-get 'dired-filename context)))
+ (dired-goto-file f)
+ (when-let ((p (alist-get 'position context)))
+ (goto-char p)))
+ (setq point (point))))
+ (set-window-point w point))))
(setq dired-switches-alist nil)
(hack-dir-local-variables-non-file-buffer) ; before sorting
(dired-sort-other dired-actual-switches t)
This bug report was last modified 1 year and 102 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.