From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: log-edit-strip-single-file-name Date: Wed, 3 Feb 2010 23:51:31 -0800 (PST) Message-ID: <201002040751.o147pVEb025009@godzilla.ics.uci.edu> References: <3a26oiti.fsf@fencepost.gnu.org> <12bpggw4wg.fsf@fencepost.gnu.org> <201001290820.o0T8KCv1022959@godzilla.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1265271100 16832 80.91.229.12 (4 Feb 2010 08:11:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Feb 2010 08:11:40 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 04 09:11:36 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NcwoH-0002Fc-Qv for ged-emacs-devel@m.gmane.org; Thu, 04 Feb 2010 09:11:34 +0100 Original-Received: from localhost ([127.0.0.1]:50387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcwoG-0001vP-MX for ged-emacs-devel@m.gmane.org; Thu, 04 Feb 2010 03:11:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NcwoA-0001uk-PB for emacs-devel@gnu.org; Thu, 04 Feb 2010 03:11:26 -0500 Original-Received: from [199.232.76.173] (port=59423 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcwoA-0001ub-3R for emacs-devel@gnu.org; Thu, 04 Feb 2010 03:11:26 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Ncwo7-0006fD-Sr for emacs-devel@gnu.org; Thu, 04 Feb 2010 03:11:25 -0500 Original-Received: from paul-mcgann-v0.ics.uci.edu ([128.195.1.147]:52422) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ncwo6-0006Q7-Uh for emacs-devel@gnu.org; Thu, 04 Feb 2010 03:11:23 -0500 Original-Received: from godzilla.ics.uci.edu (godzilla.ics.uci.edu [128.195.10.101]) by paul-mcgann-v0.ics.uci.edu (8.13.8/8.13.8) with ESMTP id o147pW4C007583 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 3 Feb 2010 23:51:32 -0800 Original-Received: (from dann@localhost) by godzilla.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id o147pVEb025009; Wed, 3 Feb 2010 23:51:31 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Fri, 29 Jan 2010 12:58:15 -0500") Original-Lines: 104 X-ICS-MailScanner-Information: Please send mail to helpdesk@ics.uci.edu or more information X-ICS-MailScanner-ID: o147pW4C007583 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-0.34, required 5, autolearn=disabled, ALL_TRUSTED -1.44, FM_MULTI_ODD2 1.10) X-ICS-MailScanner-From: dann@godzilla.ics.uci.edu X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:120887 Archived-At: Stefan Monnier writes: > >> >>> Should I be setting log-edit-strip-single-file-name to nil when using > >> > [...] > >> >>> If so, it should probably be in Emacs's .dir-locals.el. > >> >> Agreed, > >> > It doesn't work. I guess dir-locals doesn't affect buffers not > >> > visiting files. > >> > >> This is a "general" problem that we may want to solve: non-file (nor > >> dired) buffers that are (loosely) associated with a particular > >> directory should probably obey .dir-locals.el. > > > How about solvin specific instances of this problem by calling > > `hack-dir-local-variables' from `log-edit-mode' and other VC related > > modes? > > Doesn't sound too bad. Just try and make sure the log-edit part of the > code is as clean as possible (i.e. modify hack-dir-local-variables or > provide a wrapper or a different function if extra work is needed), so > we have a clear path to add that functionality on other codes > (e.g. vc-dir, diff-mode, ...). Here's the first cut, that amazingly works. log-edit-strip-single-file-name is set correctly from .dir-locals.el after this patch. (the code that sets the local variables in hack-dir-local-variables-non-file-buffer should be put in a function that is also called from hack-local-variables). WDYT? --- files.el.~1.1104.~ 2009-12-17 08:08:20.000000000 -0800 +++ files.el 2010-02-03 23:38:35.000000000 -0800 @@ -3403,20 +3403,21 @@ is found. Returns the new class name." (nth 5 (file-attributes file))) class-name))) -(defun hack-dir-local-variables () - "Read per-directory local variables for the current buffer. +(defun hack-dir-local-variables (&optional dname) + "Read per-directory local variables. +If DNAME is set look in that directory, if not look current buffer's default directory. Store the directory-local variables in `dir-local-variables-alist' and `file-local-variables-alist', without applying them." (when (and enable-local-variables - (buffer-file-name) - (not (file-remote-p (buffer-file-name)))) + (or dname (buffer-file-name)) + (not (file-remote-p (or dname (buffer-file-name))))) ;; Find the variables file. - (let ((variables-file (dir-locals-find-file (buffer-file-name))) + (let ((variables-file (dir-locals-find-file (or dname (buffer-file-name)))) (class nil) (dir-name nil)) (cond ((stringp variables-file) - (setq dir-name (file-name-directory (buffer-file-name))) + (setq dir-name (or dname (file-name-directory (buffer-file-name)))) (setq class (dir-locals-read-from-file variables-file))) ((consp variables-file) (setq dir-name (nth 0 variables-file)) @@ -3433,6 +3434,18 @@ and `file-local-variables-alist', withou (push elt dir-local-variables-alist)) (hack-local-variables-filter variables dir-name))))))) + +(defun hack-dir-local-variables-non-file-buffer (dname) + (hack-dir-local-variables dname) + (when file-local-variables-alist + ;; Any 'evals must run in the Right sequence. + (setq file-local-variables-alist + (nreverse file-local-variables-alist)) + (run-hooks 'before-hack-local-variables-hook) + (dolist (elt file-local-variables-alist) + (hack-one-local-variable (car elt) (cdr elt)))) + (run-hooks 'hack-local-variables-hook)) + (defcustom change-major-mode-with-file-name t "Non-nil means \\[write-file] should set the major mode from the file name. --- log-edit.el.~1.56.~ 2009-10-03 03:20:50.000000000 -0700 +++ log-edit.el 2010-02-03 23:41:20.000000000 -0800 @@ -152,6 +152,8 @@ can be obtained from `log-edit-files'." "If non-nil, remove file name from single-file log entries." :type 'boolean) +(put 'log-edit-strip-single-file-name 'safe-local-variable 'booleanp) + (defvar cvs-changelog-full-paragraphs t) (make-obsolete-variable 'cvs-changelog-full-paragraphs 'log-edit-changelog-full-paragraphs @@ -365,7 +389,8 @@ commands (under C-x v for VC, for exampl \\{log-edit-mode-map}" (set (make-local-variable 'font-lock-defaults) '(log-edit-font-lock-keywords t)) - (make-local-variable 'log-edit-comment-ring-index)) + (make-local-variable 'log-edit-comment-ring-index) + (hack-dir-local-variables-non-file-buffer default-directory)) (defun log-edit-hide-buf (&optional buf where) (when (setq buf (get-buffer (or buf log-edit-files-buf)))