all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@ics.uci.edu>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: log-edit-strip-single-file-name
Date: Wed, 3 Feb 2010 23:51:31 -0800 (PST)	[thread overview]
Message-ID: <201002040751.o147pVEb025009@godzilla.ics.uci.edu> (raw)
In-Reply-To: <jwvfx5olrrl.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 29 Jan 2010 12:58:15 -0500")

Stefan Monnier <monnier@IRO.UMontreal.CA> 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))
+
 \f
 (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)))




  reply	other threads:[~2010-02-04  7:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-31  3:21 commit style redux Miles Bader
2009-04-01  0:57 ` Stefan Monnier
2010-01-16  3:00 ` Glenn Morris
2010-01-16  7:03   ` Juanma Barranquero
2010-01-16  9:10   ` Thien-Thi Nguyen
2010-01-27  4:25   ` Glenn Morris
2010-01-27 14:57     ` Stefan Monnier
2010-01-28  5:30       ` log-edit-strip-single-file-name [was Re: commit style redux] Glenn Morris
2010-01-28 19:25         ` log-edit-strip-single-file-name Stefan Monnier
2010-01-28 23:13           ` log-edit-strip-single-file-name Stefan Monnier
2010-01-29  3:06           ` log-edit-strip-single-file-name Dan Nicolaescu
2010-01-29  8:20           ` log-edit-strip-single-file-name Dan Nicolaescu
2010-01-29 17:58             ` log-edit-strip-single-file-name Stefan Monnier
2010-02-04  7:51               ` Dan Nicolaescu [this message]
2010-02-04 15:40                 ` log-edit-strip-single-file-name Stefan Monnier
2010-02-06  4:26                   ` log-edit-strip-single-file-name Dan Nicolaescu
2010-02-06 14:28                     ` log-edit-strip-single-file-name Stefan Monnier
2010-02-06 19:18                       ` log-edit-strip-single-file-name Dan Nicolaescu
2010-02-08  1:28                         ` log-edit-strip-single-file-name Stefan Monnier
2010-01-30 22:57           ` log-edit-strip-single-file-name Juri Linkov
2010-01-31  6:56             ` log-edit-strip-single-file-name Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201002040751.o147pVEb025009@godzilla.ics.uci.edu \
    --to=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.