You are not logged in.
Pages: 1
Hi,
Can additional words be defined for highlighting in mousepad?.
For example, Octave has do - until loops, "do" is currently shown in bold but "until" not.
Thanks
Offline
It is provided by the GtkSource library. Depending on what version of it you have, the language specs are located in /usr/share/gtksourceview-*. You can perform a quick search like so:
find /usr/share/gtksourceview-*/ -iname '*octave*'
A quick look suggests that until is defined as a keyword in both gtksourceview-3.0 and gtksourceview-4, and indeed, it's highlighted in Mousepad 0.4.2.
Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please!
Offline
Thanks.
I'm using MP 0.5.8 .
As mentioned "do" is shown in bold but "until" isn't.
How can this be fixed?.
Last edited by jt1122 (2022-07-07 12:36:25)
Offline
Ok. Can you post the relevant part of octave.lang?
sed -n '209,249p' /usr/share/gtksourceview-4/language-specs/octave.lang
Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please!
Offline
Sure:
<context id="octave-matlab-keyword" style-ref="keyword">
<!--
Octave and Matlab have already implemented most of each others keywords
but not all. Both Octave and Matlab are still missing keywords from the
other. As such, this block only has the keywords already implemented in
both. When adding a new keyword, make sure you place it on the right
place.
-->
<keyword>break</keyword>
<keyword>case</keyword>
<keyword>catch</keyword>
<keyword>classdef</keyword>
<keyword>continue</keyword>
<keyword>do</keyword>
<keyword>else</keyword>
<keyword>elseif</keyword>
<keyword>end</keyword>
<keyword>enumeration</keyword>
<keyword>events</keyword>
<keyword>for</keyword>
<keyword>function</keyword>
<keyword>if</keyword>
<keyword>methods</keyword>
<keyword>otherwise</keyword>
<keyword>parfor</keyword>
<keyword>properties</keyword>
<keyword>return</keyword>
<keyword>switch</keyword>
<keyword>try</keyword>
<keyword>until</keyword>
<keyword>varargin</keyword>
<keyword>varargout</keyword>
<keyword>while</keyword>
</context>
</include>
</context>
<context id="builtin" style-ref="builtin">
<!-- If any of these is between "." it's a struct. -->
<prefix>(?<!\.)\%[</prefix>
<suffix>\%](?!\.)</suffix>
Offline
Can you check if that file is read by removing the line for do? You can also comment it out, if you'd like:
<!-- <keyword>do</keyword> -->
By any chance, did you compile Mousepad from source?
Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please!
Offline
Thanks.
I've changed the file, no difference.
Didn't compile from source, simple apt install.
Last edited by jt1122 (2022-07-07 13:13:01)
Offline
By "no difference" do you mean that the do keyword got shown even after you commented it out? Did you close your active Mousepad windows and then reopen them?
Is the keyword not recognized in all of your source files or in one specific file?
What's the file extension that you use for them? Can you post the part of the source code that's not getting picked up?
Also, just to make sure: have you selected a color scheme in Preferences and have you set filetype to Octave?
Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please!
Offline
"no difference" means "until" still doesn't show in bold.
Offline
My apologies for not being clear, but what we tried to do is to check whether the file /usr/share/gtksourceview-4/language-specs/octave.lang is read at all. After you've commented out or removed the line for the do keyword (forget about until for a moment), did it affect its appearance in your code? Was it still being highlighted in bold or not? Determining this would provide us more hints as to what's actually happening.
Since the keywords are properly defined in the langspec file, my suspicions are: 1) you're not setting the filetype to the correct one in Document > Filetype > Scientific > Octave; or 2) you have unterminated quotes on the same line as the until keyword (double-check your code).
Hopefully, I've made myself clear now.
Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please!
Offline
Instead of editing system files, you can copy them in ~/.local/share/gtksourceview-4/language-specs (to be created if needed) and do your tests there.
`until` is properly highlighted for me though, and it should be for you given what you show in #5.
Don't you already have something in ~/.local/share/gtksourceview-4/language-specs that overrides it?
Offline
Thanks for the replies.
I've manually set the document type: Document->File Type->Scientific->Matlab
& not everything is highlighted as expected.
But doesn't MP recognize it's an Octave/Matlab file to "auto-select" the proper highlighting?.
Offline
This is difficult: Matlab is a sub-language of Octave, so it is not always possible to distinguish. If the `.m` extension is present, GSV favors Octave internally I think. Otherwise Mousepad uses `g_content_type_guess()` which detects Matlab.
Be careful though: if you force the language recognition to Matlab, Mousepad will remember your choice and stay on it afterwards (if the recent file history is not disabled).
But why put Matlab, when Octave is the right language?
Offline
Thanks.
I see there's a separate entry for Octave so I've chosen that now (and bold text is as expected).
But my question remains - Octave also has a ".m" suffix. isn't that auto-recognized by MP?
Offline
As I tried to explain above, Mousepad and its dependencies try to do what they can about it. For me (on Arch Linux) `.m` files are automatically recognized as Octave files, but it may depend on the version of GSV, GLib and shared-mime-info, at least.
Offline
Thanks. so there are no config files to tweak to ensure ".m" is recognized?.
Offline
No I don't think so, but here's what you can do to force recognition:
mkdir -p ~/.local/share/gtksourceview-4/language-specs
cp /usr/share/gtksourceview-4/language-specs/octave.lang ~/.local/share/gtksourceview-4/language-specs/matlab.lang
sed -i 's/id="octave"/id="matlab"/' ~/.local/share/gtksourceview-4/language-specs/matlab.lang
Offline
Pages: 1
[ Generated in 0.011 seconds, 7 queries executed - Memory usage: 597.84 KiB (Peak: 614.32 KiB) ]