Merge lp:~mefrio-g/scratch/bug-139057 into lp:~elementary-apps/scratch/scratch

Proposed by Mario Guerriero
Status: Rejected
Rejected by: Gero.Bare
Proposed branch: lp:~mefrio-g/scratch/bug-139057
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 165 lines (+122/-0)
4 files modified
CMakeLists.txt (+2/-0)
data/language-specs/mustache.lang (+109/-0)
src/Services/Document.vala (+10/-0)
src/config.vala.cmake (+1/-0)
To merge this branch: bzr merge lp:~mefrio-g/scratch/bug-139057
Reviewer Review Type Date Requested Status
Gero.Bare (community) Disapprove
Review via email: mp+278195@code.launchpad.net

Description of the change

Fix bug #139057

Make adding support for new languages easier. You just need to add the .lang file in the data/language-specs if you want to add support for a new language.

To post a comment you must log in.
lp:~mefrio-g/scratch/bug-139057 updated
1594. By Mario Guerriero

using personal language-specs folder

Revision history for this message
Gero.Bare (gero-bare) wrote :

Ok this seems to work fine, but it's missing something important.
A license.

The first time I saw it, I missed it, but there's no license.
The license needs to be free software (or equivalent that allow redistribution, modify, etc).

Contact the creator, we don't need a permission, that wont work we need a free license (or equivalent, MIT, apache, lgpl, gpl3, BSD).

The lang spec, needs to have the copyright notice, and if the license is not gpl 2, it should be packed with scratch... that part goes beyond my knowledge so you will need to ask ric*tz, or c*dy, or daniel.

Also I didn't know you only need it to copy the lang spec file to /home/<user>/.local/share/gtksourceview-3.0/language-specs

Which defeat most of the purpose of this. I don't know, we might need to discuss this part further.

review: Needs Fixing
Revision history for this message
Gero.Bare (gero-bare) wrote :

Ok, I don't think this is a good Idea.

I discussed this, the proper action is to add the file to GtkSourceView, and not here.

The license issue remains, so if you want to add it to Gtksourceview you have 2 path.
Contact the people of GtkSourceview, or convince some one that is responsible to pack Gtksourceview for elementary to be added there.

Ideally this should be fixed upstream.

I need to disapprove this.

review: Disapprove
Revision history for this message
Mario Guerriero (mefrio-g) wrote :

Thanks for the review. I posted a patch for the upstream project.

https://bugzilla.gnome.org/show_bug.cgi?id=741626

Unmerged revisions

1594. By Mario Guerriero

using personal language-specs folder

1593. By Mario Guerriero

fixed #1390577

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-09-01 09:34:28 +0000
3+++ CMakeLists.txt 2015-11-21 15:15:56 +0000
4@@ -6,6 +6,7 @@
5 enable_testing ()
6 include (GNUInstallDirs)
7 set (DATADIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/scratch")
8+set (LANGUAGE_SPECS_DIR "${DATADIR}/language-specs")
9 set (SCRIPTDIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/scratch/scripts")
10 set (PKGDATADIR "${DATADIR}/scratch")
11 set (GETTEXT_PACKAGE "scratch-text-editor")
12@@ -101,3 +102,4 @@
13
14 # Data
15 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/scratch-text-editor.desktop DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/applications)
16+install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/language-specs DESTINATION ${DATADIR})
17
18=== added directory 'data/language-specs'
19=== added file 'data/language-specs/mustache.lang'
20--- data/language-specs/mustache.lang 1970-01-01 00:00:00 +0000
21+++ data/language-specs/mustache.lang 2015-11-21 15:15:56 +0000
22@@ -0,0 +1,109 @@
23+<?xml version="1.0" encoding="UTF-8"?> <!--
24+
25+ ╔══════════════════════════════════════════════════════════╗
26+ ║ Author: denim2x <https://github.com/denim2x> ║
27+ ╟──────────────────────────────────────────────────────────╢
28+ ║ This file provides syntax highlighting for the Mustache ║
29+ ║ language within editors based on GtkSourceView; based on ║
30+ ║ asp.lang <https://goo.gl/1lrGu6>. ║
31+ ╚══════════════════════════════════════════════════════════╝
32+
33+-->
34+<language id="mustache" _name="Mustache" version="2.0" _section="Markup">
35+ <metadata>
36+ <property name="mimetypes">text/x-handlebars-template;text/html</property>
37+ <property name="globs">*.handlebars;*.hbs;*.hgn;*.hjs;*.mu;*.mustache;*.stache</property>
38+ <property name="block-comment-start">{{!</property>
39+ <property name="block-comment-end">}}</property>
40+ </metadata>
41+
42+ <styles>
43+ <style id="comment" _name="Comment" map-to="def:comment" />
44+ <style id="delimiter" _name="Delimiter" map-to="def:type" />
45+ <style id="key" _name="Key" map-to="def:identifier" />
46+ <style id="operator" _name="Operator" map-to="def:operator" />
47+ <style id="partial" _name="Partial" map-to="def:preprocessor" />
48+ <style id="section" _name="Section" map-to="def:statement" />
49+ <style id="tag" _name="Tag" map-to="def:keyword" />
50+ <style id="variable" _name="Variable" map-to="def:function" />
51+ <style id="unescaped" _name="Unescaped" map-to="def:constant" />
52+ </styles>
53+
54+ <definitions>
55+ <context id="comment" style-ref="comment">
56+ <start>\{\{\!</start>
57+ <end>\}\}</end>
58+ <include>
59+ <context ref="def:in-comment"/>
60+ </include>
61+ </context>
62+
63+ <context id="delimiter" style-ref="delimiter">
64+ <start>\{\{=</start>
65+ <end>=\}\}</end>
66+ <include>
67+ <context ref="def:string"/>
68+ </include>
69+ </context>
70+
71+ <context id="key" style-ref="key">
72+ <match>[a-zA-Z_][a-zA-Z0-9_]*</match>
73+ </context>
74+
75+ <context id="partial" style-ref="partial">
76+ <start>\{\{&gt;</start>
77+ <end>\}\}</end>
78+ <include>
79+ <context ref="key"/>
80+ </include>
81+ </context>
82+
83+ <context id="section" style-ref="section">
84+ <start>\{\{([#^/])</start>
85+ <end>(\?)?\}\}</end>
86+ <include>
87+ <context sub-pattern="0" where="start" style-ref="operator"/>
88+ <context sub-pattern="0" where="end" style-ref="operator"/>
89+ <context ref="key"/>
90+ </include>
91+ </context>
92+
93+ <context id="unescaped" style-ref="unescaped">
94+ <start>\{\{\{</start>
95+ <end>\}\}\}</end>
96+ <include>
97+ <context ref="key"/>
98+ </include>
99+ </context>
100+
101+ <context id="unescaped-amp" style-ref="unescaped">
102+ <start>\{\{&amp;</start>
103+ <end>\}\}</end>
104+ <include>
105+ <context ref="key"/>
106+ </include>
107+ </context>
108+
109+ <context id="variable" style-ref="variable">
110+ <start>\{\{</start>
111+ <end>\}\}</end>
112+ <include>
113+ <context ref="key"/>
114+ </include>
115+ </context>
116+
117+ <context id="mustache" class="no-spell-check">
118+ <include>
119+ <context ref="comment" />
120+ <context ref="delimiter" />
121+ <context ref="partial" />
122+ <context ref="section" />
123+ <context ref="unescaped" />
124+ <context ref="unescaped-amp" />
125+ <context ref="variable" />
126+ <context ref="html:html" />
127+ </include>
128+ </context>
129+
130+ </definitions>
131+</language>
132\ No newline at end of file
133
134=== modified file 'src/Services/Document.vala'
135--- src/Services/Document.vala 2015-09-16 01:11:55 +0000
136+++ src/Services/Document.vala 2015-11-21 15:15:56 +0000
137@@ -90,6 +90,16 @@
138 this.main_actions = actions;
139 this.file = file;
140
141+ // Change directories list where gtksourceview looks for language files
142+ Gtk.SourceLanguageManager manager = Gtk.SourceLanguageManager.get_default ();
143+ string[] search_path = manager.get_search_path ();
144+ string[] custom_search_path = new string[search_path.length + 1];
145+ int i;
146+ for (i = 0; i < search_path.length; i++)
147+ custom_search_path[i] = search_path[i];
148+ custom_search_path[i] = Constants.LANGUAGE_SPECS_DIR;
149+ manager.set_search_path (custom_search_path);
150+
151 open.begin ();
152 }
153
154
155=== modified file 'src/config.vala.cmake'
156--- src/config.vala.cmake 2014-11-12 11:20:08 +0000
157+++ src/config.vala.cmake 2015-11-21 15:15:56 +0000
158@@ -8,6 +8,7 @@
159 public const string VERSION_INFO = "@VERSION_INFO@";
160 public const string PLUGINDIR = "@PLUGINDIR@";
161 public const string INSTALL_PREFIX = "@CMAKE_INSTALL_PREFIX@";
162+ public const string LANGUAGE_SPECS_DIR = "@LANGUAGE_SPECS_DIR@";
163
164 /* Translatable launcher (.desktop) strings to be added to */
165 /* template (.pot) file. These strings should reflect any */

Subscribers

People subscribed via source and target branches