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: 25.3; wrong handling ~/.cpp.el Date: Fri, 20 Oct 2017 04:12:01 +0900 (JST) Organization: Red Hat Japan, Inc. Message-ID: <20171020.041201.1999615195231557431.yamato@redhat.com> References: <20171017.192303.945206897976012626.yamato@redhat.com> <871sm2gd1g.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1508440390 17341 195.159.176.226 (19 Oct 2017 19:13:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 19 Oct 2017 19:13:10 +0000 (UTC) Cc: 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 Thu Oct 19 21:13:07 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 1e5GFd-0003kM-Gj for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Oct 2017 21:13:05 +0200 Original-Received: from localhost ([::1]:50891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5GFk-0006Fs-Hl for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Oct 2017 15:13:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5GFd-0006Fm-Ou for bug-gnu-emacs@gnu.org; Thu, 19 Oct 2017 15:13:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5GFa-0004j2-JH for bug-gnu-emacs@gnu.org; Thu, 19 Oct 2017 15:13:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5GFa-0004iu-FR for bug-gnu-emacs@gnu.org; Thu, 19 Oct 2017 15:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e5GFa-0005H4-8e for bug-gnu-emacs@gnu.org; Thu, 19 Oct 2017 15:13: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: Thu, 19 Oct 2017 19:13: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.150844033320206 (code B ref 28685); Thu, 19 Oct 2017 19:13:02 +0000 Original-Received: (at 28685) by debbugs.gnu.org; 19 Oct 2017 19:12:13 +0000 Original-Received: from localhost ([127.0.0.1]:50717 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5GEn-0005Fq-BR for submit@debbugs.gnu.org; Thu, 19 Oct 2017 15:12:13 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:59830) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5GEj-0005FS-Ky for 28685@debbugs.gnu.org; Thu, 19 Oct 2017 15:12:11 -0400 Original-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E35894A706; Thu, 19 Oct 2017 19:12:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E35894A706 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=yamato@redhat.com Original-Received: from localhost (unknown [10.64.242.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id CEC935D6A4; Thu, 19 Oct 2017 19:12:02 +0000 (UTC) In-Reply-To: <871sm2gd1g.fsf@users.sourceforge.net> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 19 Oct 2017 19:12:04 +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:138725 Archived-At: commit 784582fa24623a3658d25e211f98c28212ff628d (HEAD -> cpp-highlight-check) Author: Masatake YAMATO Date: Fri Oct 20 04:10:28 2017 +0900 Put cpp config file to ~/.emacs.d/cpp.el if possible If `cpp-config-file` starts with '.', remove the '.' when putting the file to ~/.emacs.d. Suggested by Noam Postavsky * lisp/progmodes/cpp.el (cpp-locate-user-emacs-file): New function wrapping `locate-user-emacs-file`. (cpp-edit-load): Use `cpp-locate-user-emacs-file`. (cpp-edit-save): Ditto. diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el index 0a68a0cf2c..c1f7088895 100644 --- a/lisp/progmodes/cpp.el +++ b/lisp/progmodes/cpp.el @@ -568,6 +568,14 @@ cpp-edit-reset (set-window-start nil start) (goto-char pos))) +(defun cpp-locate-user-emacs-file (file) + (locate-user-emacs-file + ;; Remove initial '.' from file. + (if (eq (aref file 0) ?.) + (substring file 1) + file) + file)) + (defun cpp-edit-load () "Load cpp configuration." (interactive) @@ -576,8 +584,8 @@ cpp-edit-load nil) ((file-readable-p cpp-config-file) (load-file cpp-config-file)) - ((file-readable-p (locate-user-emacs-file cpp-config-file)) - (load-file (locate-user-emacs-file cpp-config-file)))) + ((file-readable-p (cpp-locate-user-emacs-file cpp-config-file)) + (load-file (cpp-locate-user-emacs-file cpp-config-file)))) (if (derived-mode-p 'cpp-edit-mode) (cpp-edit-reset))) @@ -588,7 +596,7 @@ cpp-edit-save (with-current-buffer cpp-edit-buffer (let* ((config-file (if (file-writable-p cpp-config-file) cpp-config-file - (locate-user-emacs-file cpp-config-file))) + (cpp-locate-user-emacs-file cpp-config-file))) (buffer (find-file-noselect config-file)) ) (set-buffer buffer)