From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: calling desktop-read interactively Date: Thu, 26 Sep 2019 09:20:19 -0700 (PDT) Message-ID: <7bd1b73c-cff0-4fae-a1fb-db72fdd41a10@default> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="120890"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Emacs developers To: Stefan Monnier , Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 26 18:29:48 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iDWeJ-000VI9-2C for ged-emacs-devel@m.gmane.org; Thu, 26 Sep 2019 18:29:47 +0200 Original-Received: from localhost ([::1]:40676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDWeH-00039N-E5 for ged-emacs-devel@m.gmane.org; Thu, 26 Sep 2019 12:29:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39900) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDWXP-0006r5-1G for emacs-devel@gnu.org; Thu, 26 Sep 2019 12:22:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDWXI-0001YX-LF for emacs-devel@gnu.org; Thu, 26 Sep 2019 12:22:35 -0400 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:55294) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iDWXG-0001VF-SE for emacs-devel@gnu.org; Thu, 26 Sep 2019 12:22:31 -0400 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8QGE4SU139172; Thu, 26 Sep 2019 16:22:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=ZTkMC5ziyj2A4g/ON9/fHMP9usmj+lxADHhXgTedW1Y=; b=AQebpeixKPB5wKR3fFxeTVd+sR8bHAGzTTLB2L08qIrzWahKb0kCAt2SBD1vaN2kmcNh 5gbcfSyMmnXGKOkwpANmPkECunz5o6dlOHw7pOyfYJ0T3BpdafuYQp6OabfpDh19+DhI /VaidDzb0cEGOUQdU45fpxGLP6D7b2jCqixga1FvTa8U5Tq3nM50oI9iljNcu3menjps 7xD8cY+rZ6JIpO36XSaFr1+0GLnNn+KcPSY4BKdBYJRuxjgF2yoZaip/mTOr0he7smuH Uu6gR1O7UeTH1ABUzlokSh9qsyg7V9pCt/8GR5KOVtlHjSTi5kbMfsN2TvkGClW1nYc4 6Q== Original-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2v5btqcxse-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Sep 2019 16:22:22 +0000 Original-Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8QGE77K074250; Thu, 26 Sep 2019 16:20:21 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2v8yjww6ss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Sep 2019 16:20:21 +0000 Original-Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x8QGKKek004893; Thu, 26 Sep 2019 16:20:20 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4888.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9392 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909260143 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9392 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909260143 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240311 Archived-At: > > So, if we were to support multiple filenames, it surely wouldn't just b= e > > changing desktop-read to ask for the file name, but fully support multi= ple > > desktop files everywhere. >=20 > Indeed. >=20 > > That's a feature nobody's asked for before, I think. See below. > It just seems so weird to only be able to specify the file indirectly via > the dir in which it lives. Seems weird indeed. I've never understood the why of that design. > It works OK if you have different "desktops" > for different projects placed in different subdirectories, but if you > have different "desktops" for different kinds of sessions (e.g. one for > email, one for programming, ...) then having to place the desktops in > different subdirectories feels awkward (especially since there isn't > necessarily many more files to put in those directories). >=20 > Being *able* to specify a directory is great. Being limited to that is o= dd. Sincere apologies for jumping in here, especially without reading all of the thread. FWIW, I have, I'm pretty sure, asked for exactly that feature. Or at least I've mentioned that it is, IMO, a failing that the design of desktop.el is _only_ directory-oriented, assuming that you want/need at most one desktop file per directory. (Why was such an assumption made? I've never understood it.) Long ago I implemented this feature - ability to read a desktop file anywhere, i.e., by file name, in the Bookmark+ code. There, users can have any number of desktop files, in any directories. They can create bookmarks for them, and so restore desktops by jumping to bookmarks. Function `bmkp-desktop-read' reads a desktop file. Maybe it will help, e.g. by saving a little time, to take a look at that code. It's in file bookmark+-1.el, here: https://www.emacswiki.org/emacs/download/bookmark%2b-1.el Anyway, here is that code: ;; Derived from code in `desktop-read'. (defun bmkp-desktop-read (file) "Load desktop-file FILE, then run `desktop-after-read-hook'. Return t if FILE was loaded, nil otherwise." (interactive) (unless (file-name-absolute-p file) ; Should never happen. (setq file (expand-file-name file bmkp-desktop-default-directory))) (when (file-directory-p file) (error "`%s' is a directory, not a file" fi= le)) (setq desktop-dirname (file-name-directory file)) (if (not (file-readable-p file)) nil ; Return nil, meaning not loaded. (let ((desktop-restore-eager t) ; Don't bother with lazy restore. (desktop-first-buffer nil) (desktop-buffer-ok-count 0) (desktop-buffer-fail-count 0) (desktop-save nil)) ; Prevent desktop saving during= eval of desktop buffer. (when (fboundp 'desktop-lazy-abort) (desktop-lazy-abort)) ; Emacs 22+= . (load file t t t) (when (boundp 'desktop-file-modtime) ; Emacs 22+ (setq desktop-file-modtime (nth 5 (file-attributes file)))) ;; `desktop-create-buffer' puts buffers at end of the buffer list. ;; We want buffers existing prior to evaluating the desktop (and not = reused) to be placed ;; at the end of the buffer list, so we move them here. (mapc 'bury-buffer (nreverse (cdr (memq desktop-first-buffer (nrevers= e (buffer-list)))))) (bmkp--pop-to-buffer-same-window (car (buffer-list))) (run-hooks 'desktop-delay-hook) (setq desktop-delay-hook ()) (run-hooks 'desktop-after-read-hook) (when (boundp 'desktop-buffer-ok-count) ; Emacs 22+ (message "Desktop: %d buffer%s restored%s%s." desktop-buffer-ok-cou= nt (if (=3D 1 desktop-buffer-ok-count) "" "s") (if (< 0 desktop-buffer-fail-count) (format ", %d failed to restore" desktop-buffer-fail-c= ount) "") (if (and (boundp 'desktop-buffer-args-list) desktop-buffe= r-args-list) (format ", %d to be restored lazily" (length desktop-b= uffer-args-list)) ""))) t))) If something that offers the same thing becomes available in vanilla Emacs then, at least for the most recent releases, the Bookmark+ code can just make use of the vanilla function. If not, that's OK too. HTH.