From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sergey Organov Newsgroups: gmane.emacs.devel Subject: Re: Tweaking save-some-buffers-action-alist Date: Fri, 18 Jun 2021 22:16:20 +0300 Message-ID: <878s37j857.fsf@osv.gnss.ru> References: <87y2b879ni.fsf@osv.gnss.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15500"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Daniel =?utf-8?Q?Mart=C3=ADn?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 18 21:19:27 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1luK1X-0003qw-74 for ged-emacs-devel@m.gmane-mx.org; Fri, 18 Jun 2021 21:19:27 +0200 Original-Received: from localhost ([::1]:53140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luK1W-0007kx-96 for ged-emacs-devel@m.gmane-mx.org; Fri, 18 Jun 2021 15:19:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luJyg-0005JE-Nf for emacs-devel@gnu.org; Fri, 18 Jun 2021 15:16:30 -0400 Original-Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]:46631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luJyb-0001IK-TI for emacs-devel@gnu.org; Fri, 18 Jun 2021 15:16:30 -0400 Original-Received: by mail-lf1-x131.google.com with SMTP id m21so18284498lfg.13 for ; Fri, 18 Jun 2021 12:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=sXLnioRgT6JIe9Y8Eezr7EHN0ZVdEVzBaSpic/ICQ3U=; b=dlu/UDzJPSGIbrOh1hqIRPKyMVyHmVx8jxJ/+pGDH3wuK3j5prTLb0/9i2WQDdYueo pqmWVl0EEeV34BesulAuwgx/1hoczcO5LhOv0t9SYNAUtWfiDaH36Tj/63snqj7N1myW nbIAf3DPWI/JlVwyPDlQNiSkH6fwKOA/zp8HibOwyarAIjHcOZPIJdVOn4M60uhDcxdl 0S9rRoVC9osxeXofcsQT5BrJic72iuEpkSmefsFJ24E5RNGZuy4uK5Mq2TgOJ9scY+Bd GufHzBLgKGf6KssgyPfERFXrVScdl33PX9lri2kEez1xSZFQfW9ZPwpti5PUKv+EzbeZ 9hwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=sXLnioRgT6JIe9Y8Eezr7EHN0ZVdEVzBaSpic/ICQ3U=; b=FzI6Vf/jAG4WPDUu7xTUQENHCuQq3QbcyJTIrMWH1rjm1OKNShLDWQGbsxnSYPdzhV 1vmaIz/6czfN5vh7kyPzai/12mkUT49OeTP3Bkm5g44lk+TEmt95bsdFq+3ZFPcNWnyq /stc0b/VagNhVEvXQ1xfobAe8/WLGEC4G5sUIF6EThwC9BFqS6LkpjLF1Uvcl0XbFXg6 FXvJoBpru61S6IA6RIQziLiI/psEm4RdPgrJtLOemudNmIqTLzHoAPUQEue8C2525gP0 dPke+vC3FISL30RbGMFxpCBfTsoEkl33q2Hfr6wC/7mxtqJJLMuHgBa6VKd1e7M3o6Po Rk6w== X-Gm-Message-State: AOAM532SEaj0jLV8WddaLKDLHEO+puZCJa+9MavvSog5sZc2EfCQSC4l ZUShIG1iLbhIZ1YeZPbFh01dsyhSIjs= X-Google-Smtp-Source: ABdhPJzdEbVXQ7GBstewG6ObN9UIGV8RCkk+W8Jroj2QI927AasE5GGKoci2dhVnBEkfys47CmGTow== X-Received: by 2002:a05:6512:2206:: with SMTP id h6mr4626606lfu.345.1624043782163; Fri, 18 Jun 2021 12:16:22 -0700 (PDT) Original-Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id g20sm1154645lja.2.2021.06.18.12.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:16:21 -0700 (PDT) In-Reply-To: ("Daniel =?utf-8?Q?Mart=C3=ADn=22's?= message of "Thu, 17 Jun 2021 23:55:54 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::131; envelope-from=sorganov@gmail.com; helo=mail-lf1-x131.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:270914 Archived-At: Daniel Martín writes: > Sergey Organov writes: > >> >> #+BEGIN_SRC emacs-lisp >> (nconc >> save-some-buffers-action-alist >> '((?\C-\M-g >> (lambda (buf) >> (with-current-buffer buf >> (revert-buffer))) >> "revert this buffer"))) >> #+END_SRC >> >> I'm concerned as I use `nconc` that sounds unsafe, and then original >> definition has some ",(" and ",(purecopy" tricks that I dunno if I need >> to follow, and if so, how? > > Purecopy is a no-op except while Emacs is being built and dumped, so > user customizations can omit it. Evaluate (info "(elisp) Pure Storage") > in Emacs to read more about this. > > Backquoting the alist will instruct the Elisp interpreter to not > evaluate KEY, but evaluate the lambda FUNC. Evaluating lambda > expressions is generally a good idea because that enables > byte-compilation and all its benefits: Faster code, less memory usage, > some static checks, specially under lexical scope, etc. Thanks for clarification and pointers! Is `nconc` safe here, or should I `copy-seq` the original and modify that instead? > >> >> And to finally justify posting to 'emacs-devel', does it make sense to >> add this capability to the default value of >> `save-some-buffers-action-alist`? >> > > I think reverting a buffer when compiling is not a very common need. Surprisingly, it /is/ rather common when one has a lot of (often unrelated to compilation) buffers, and finding the buffer in question after compilation just to revert it is boring and is often forgotten until the next compilation. Annoying. > More importantly, the prompt already has a lot of options and adding one > more will make it more complex and difficult to understand. Well, yes, but I believe that the "Discard changes" option is the second or third by usefulness among the rest supported: "Save Changes, Discard Changes, Save All". To me it's "Ignore the change and continue" that seems to be the least useful one. I just want to have a way to finish entire prompt series and have no modified buffers at the end. Doesn't seem to be too much to ask for. As a side note, if there are too many options already, 'C-r' could be removed and the buffer in question be shown automatically instead. > At some point you have to draw the line between what should be a > customization and what should be included in Emacs Yep. I just think that the line in this particular case has been chosen long ago, when `enable-recursive-minibuffers` was enabled by default, or was unheard of, and now, when it is disabled by default, the line should be drawn at a different level, making it possible again to conveniently revert the buffer. > and I think your suggestion can perfectly be a personal customization. Probably it could, but right now it isn't. I don't think we can expect a novice user to be able to tweak it like I did above, no way. Do you in fact suggest to support this through `customize` or what? The current state is that to the actual question I got from a novice user: "How do I discard changes to the buffer when I run `compile` and Emacs asks me if I want to save some?" I have to either give the "No way" answer, or tweak Emacs for them. Sad. BTW, if there were a way to cancel the `save-some-buffers` after 'C-r' yet leave the modified buffer current, it'd solve the issue as well, though in a different, less convenient way. Thanks, -- Sergey Organov