From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.bugs Subject: bug#28685: [PATCH 1/3] Fix reading and writing cpp-config-file under home directory Date: Sun, 22 Oct 2017 18:22:40 +0900 Message-ID: <20171022092242.7014-1-yamato@redhat.com> References: <87a80kdzod.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1508664268 7005 195.159.176.226 (22 Oct 2017 09:24:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 22 Oct 2017 09:24:28 +0000 (UTC) Cc: yamato@redhat.com, 28685@debbugs.gnu.org To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 22 11:24:23 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e6CUP-00089v-B5 for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Oct 2017 11:24:13 +0200 Original-Received: from localhost ([::1]:60556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6CUW-0007ir-Cz for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Oct 2017 05:24:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6CUH-0007iF-L2 for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 05:24:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6CUE-0003JW-G3 for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 05:24:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46244) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e6CUE-0003JQ-CQ for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 05:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e6CUE-0005f9-32 for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 05:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Masatake YAMATO Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Oct 2017 09:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28685 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 28685-submit@debbugs.gnu.org id=B28685.150866418721676 (code B ref 28685); Sun, 22 Oct 2017 09:24:02 +0000 Original-Received: (at 28685) by debbugs.gnu.org; 22 Oct 2017 09:23:07 +0000 Original-Received: from localhost ([127.0.0.1]:54919 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e6CTL-0005dY-Mq for submit@debbugs.gnu.org; Sun, 22 Oct 2017 05:23:07 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:56682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e6CTK-0005cp-BL for 28685@debbugs.gnu.org; Sun, 22 Oct 2017 05:23:06 -0400 Original-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF61E85376; Sun, 22 Oct 2017 09:22:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BF61E85376 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=yamato@redhat.com Original-Received: from master.redhat.com (unknown [10.64.242.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A3E86060A; Sun, 22 Oct 2017 09:22:57 +0000 (UTC) In-Reply-To: <87a80kdzod.fsf@users.sourceforge.net> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 22 Oct 2017 09:22:59 +0000 (UTC) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:138845 Archived-At: * lisp/progmodes/cpp.el (cpp-edit-load): load ~/.cpp.el when it is readable. (cpp-edit-save): write to ~/.cpp.el when it is wriable. --- lisp/progmodes/cpp.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el index 8aaebdde5b..3a7dab72b4 100644 --- a/lisp/progmodes/cpp.el +++ b/lisp/progmodes/cpp.el @@ -577,7 +577,7 @@ cpp-edit-load ((file-readable-p cpp-config-file) (load-file cpp-config-file)) ((file-readable-p (concat "~/" cpp-config-file)) - (load-file cpp-config-file))) + (load-file (concat "~/" cpp-config-file)))) (if (derived-mode-p 'cpp-edit-mode) (cpp-edit-reset))) @@ -586,7 +586,11 @@ cpp-edit-save (interactive) (require 'pp) (with-current-buffer cpp-edit-buffer - (let ((buffer (find-file-noselect cpp-config-file))) + (let* ((config-file (if (file-writable-p cpp-config-file) + cpp-config-file + (concat "~/" cpp-config-file))) + (buffer (find-file-noselect config-file)) + ) (set-buffer buffer) (erase-buffer) (pp (list 'setq 'cpp-known-face @@ -601,7 +605,7 @@ cpp-edit-save (list 'quote cpp-unknown-writable)) buffer) (pp (list 'setq 'cpp-edit-list (list 'quote cpp-edit-list)) buffer) - (write-file cpp-config-file)))) + (write-file config-file)))) (defun cpp-edit-home () "Switch back to original buffer." -- 2.13.6