This file is indexed.

/usr/share/lilypond/2.14.2/scm/editor.scm is in lilypond-data 2.14.2-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
;;;; Copyright (C) 2005--2011 Jan Nieuwenhuizen <janneke@gnu.org>
;;;;
;;;; LilyPond is free software: you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation, either version 3 of the License, or
;;;; (at your option) any later version.
;;;;
;;;; LilyPond 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 General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.

(define-module (scm editor))

;; Also for standalone use, so cannot include any lily modules.
(use-modules
 (ice-9 regex)
 (srfi srfi-13)
 (srfi srfi-14))

(define PLATFORM
  (string->symbol
   (string-downcase
    (car (string-tokenize (vector-ref (uname) 0) char-set:letter)))))

(define (get-editor)
  (or (getenv "LYEDITOR")
      (getenv "XEDITOR")
      (getenv "EDITOR")

      ;; FIXME: how are default/preferred editors specified on
      ;; different platforms?
      (case PLATFORM
	((windows) "lilypad")
	(else
	 "emacs"))))

(define editor-command-template-alist
  '(("emacs" .  "emacsclient --no-wait +%(line)s:%(column)s %(file)s || (emacs +%(line)s:%(column)s %(file)s&)")
    ("gvim" . "gvim --remote +:%(line)s:norm%(column)s %(file)s")
    ("uedit32" . "uedit32 %(file)s -l%(line)s -c%(char)s")
    ("nedit" . "nc -noask +%(line)s %(file)s")
    ("gedit" . "gedit +%(line)s %(file)s")
    ("jedit" . "jedit -reuseview %(file)s +line:%(line)s")
    ("syn" . "syn -line %(line)s -col %(char)s %(file)s")
    ("lilypad" . "lilypad +%(line)s:%(char)s %(file)s")))

(define (get-command-template alist editor)
  (define (get-command-template-helper)
    (if (null? alist)
	(if (string-match "%\\(file\\)s" editor)
	    editor
	    (string-append editor " %(file)s"))
	(if (string-match (caar alist) editor)
	    (cdar alist)
	    (get-command-template (cdr alist) editor))))
  (if (string-match "%\\(file\\)s" editor)
      editor
      (get-command-template-helper)))

(define (re-sub re sub string)
  (regexp-substitute/global #f re string 'pre sub 'post))

(define (slashify x)
 (if (string-index x #\/)
     x
     (re-sub "\\\\" "/" x)))

(define-public (get-editor-command file-name line char column)
  (let* ((editor (get-editor))
	 (template (get-command-template editor-command-template-alist editor))
	 (command
	  (re-sub "%\\(file\\)s" (format #f "~S" file-name)
		  (re-sub "%\\(line\\)s" (format #f "~a" line)
			  (re-sub "%\\(char\\)s" (format #f "~a" char)
				  (re-sub
				   "%\\(column\\)s" (format #f "~a" column)
				   (slashify template)))))))
    command))