फ़ाइल के शीर्ष पर लंबी GPL कॉपीराइट सूचना छिपाएँ


10

मैं बहुत सी * cpp और * h फाइलों के साथ काम कर रहा हूं जिनमें शुरुआत में एक लंबा कॉपीराइट नोटिस होता है। मैं इन फ़ाइलों को दिखाने के लिए emacs चाहूंगा जैसे कि यह वहां नहीं था, वास्तव में पाठ को हटाए बिना।

यह है:

/*
 * Copyright (C) 2006-2008 Author A
 * Copyright (C) 2006-2008 Author B
 * Copyright (C) 2006-2008 Author C
 * Copyright (C) 2006-2008 Author D
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * As a special exception, you may use this file as part of a free
 * software library without restriction. Specifically, if other files
 * instantiate templates or use macros or inline functions from this
 * file, or you compile this file and link it with other files to
 * produce an executable, this file does not by itself cause the
 * resulting executable to be covered by the GNU General Public
 * License. This exception does not however invalidate any other
 * reasons why the executable file might be covered by the GNU Library
 * General Public License.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

 #ifndef FILENAME
 #define FILENAME
 ...

बस इस तरह दिखना चाहिए

#ifndef FILENAME
#define FILENAME
...

जवाबों:


13

Emacs के साथ आता है elide-head.elजो वास्तव में आप के लिए पूछ रहे हैं क्या करता है।

इसका उपयोग करने के लिए, elide-headएक प्रमुख मोड हुक या find-file-hook(आपके मामले में c-mode-common-hookकाम करना चाहिए) में जोड़ें। यह GPL लाइसेंस टिप्पणियों को बॉक्स से छिपा सकता है; अन्य लंबे हेडर छिपाने के लिए, अनुकूलित करें elide-head-headers-to-hide

ध्यान दें कि यह बफर के शीर्ष पर किसी भी टिप्पणी को नहीं छिपाता है, लेकिन एक लाइसेंस की शुरुआत और अंत से मेल खाने के लिए नियमित अभिव्यक्ति का उपयोग करता है।


1
मुझे यह कमांड पसंद है। बहुत अच्छा।
Tu Do

हर बार मुझे पीटता है। जब भी मैं कुछ लिखता हूं, तो कोई और था जो पहले इसके बारे में सोचता था :)
wvxvw

12

यहाँ ऐसा करने का एक तरीका है:

इसे अपनी इनिट फ़ाइल में जोड़ें:

(defun hide-banner ()
  (save-excursion
    (let* ((start (progn (beginning-of-buffer) (point)))
           (end (progn (forward-comment (buffer-size)) (point)))
           (over (make-overlay start end)))
      (overlay-put over 'invisible t))))

बफर में जहां आप प्रारंभिक टिप्पणी जोड़ना चाहते हैं:

// -*- eval: (hide-banner) -*-

या बफर हुक में समान कोड जोड़ें। या आप निश्चित रूप से जिस तरह से टिप्पणी को छिपाना चाहते हैं उसे पहचाना जा सकता है (यदि आप इसे #ifndef / #defineजोड़ी को चुनना चाहते थे , तो आपको hide-bannerपहली टिप्पणी के अंत के बजाय उसे खोजने के लिए फ़ंक्शन को संशोधित करना होगा ।


काम करता है! यह बहुत बेहतर है, धन्यवाद। यदि किसी भी बॉडी एल्स को इसकी आवश्यकता है, तो यहां मेरा हुक है:(add-hook 'c-mode-common-hook 'hide-banner)
बिगिनर
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.