How to install Jed on Arch Linux

Most Linux distros have Jed in their repos. You should install Jed whenever you set up a new Linux system. Many Linux utilities that launch a terminal based editor will default to Jed if they find it. If not they usually stick you with icky-nasty vi.

The “approved” way rather sucks. Arch based distros like Manjaro provide pamac. Arch wants everyone to do everything by themselves. First you have to find the package you want via a Web browser.

AUR package search

You have to be very careful with AUR packages. These aren’t well vetted and someone could have uploaded a malicious tweak to a trusted package. Just because you are building a package from source doesn’t mean it is safe.

Put your packages all in one place

We already installed build-devel setting up the VM. Just need to install git now.

install git
git clone https://aur.archlinux.org/jed.git
clone jed
cd jed
makepkg -si
building package

If you are curious, the s option resolves and installs dependencies. The i option installs the package after successful build. After the build chews for a while and you see all kinds of messages about fakeroot and /usr/bin/install you will finally be prompted for your password.

password prompt for install

The package may have built and installed itself in a fakeroot environment, but it won’t actually install without a valid sudo password. After that Jed is yours.

jed editing little C program

How to Install Jed from AUR on Manjaro Linux

One of the things most new (and even seasoned) users of Linux find frustrating is the organization of repositories. Linux is supposed to be the same yet when you want to install the jed text editor on Manjaro you have to go on a mining expedition and learn about the AUR (Arch User Repository).

Arch based distributions are notoriously difficult to use. Hopefully you read my earlier post about getting Boinc to run? With the Debian and RPM based distros it mostly kinda-sorta just works. Their package maintainers are incredibly remiss when it comes to including Oracle VirtualBox as a dependency, leaving people to scrounge. At least YABU distros have a custom Oracle VirtualBox package for Boinc, just the package maintainer for Boinc hasn’t been polite enough to flag as a dependency.

AUR

The Jed story is even worse. Arch based distros have created the concept of AUR (Arch User Repository). On the site it contains the following statement in bold.

DISCLAIMER: AUR packages are user produced content. Any use of the provided files is at your own risk.

If one believes all developers to be of good and decent making, this is a place for an industrious package developer to post the fruits of their labor and suddenly have it available to all ARCH based distributions. If one believes Russian/Chinese/insert-group-here hackers are out to distribute malicious code any way they can, then this is a cesspit from which there is no return.

The truth is found somewhere between those two goal posts. Most (possibly all) AUR packages must be built. If you had nothing better to do with your life you could reach and analyze each line of code before actually installing. You do that, right?

AUR is a community based thing. There are submission rules and if something is found to be malicious or non-conforming the moderators (or whatever they prefer to be called) will nuke it from AUR. Somebody, of course, must first be a victim that complains.

Given the build requirement, the very first time you install a package from AUR you get a lot of other stuff installed.

Jed command line install

AUR requires what Debian users would call “build-essentials” to be installed. Even if you never use jed as a text editor in a terminal, a new user of an Arch based distro should open a terminal window and install it first thing. You will then have most of the build environment you could ever want.

For those who just wanted the command without the knowledge, here:

sudo pamac build jed

For those who just want to search for a package in the AUR

sudo pamac search -a jed

Be warned that if you search for something common you will get a long list.

JED – golang support

I didn’t create this language support file. I’m told it even has a few minor issues. It’s just that attachments have a way of disappearing in the archives, so I’m pasting it here.

% An attempt to create a Golang mode for jed.
% Mostly gratefully stolen from pymode.
% Feel free to improve.
%
% Authors: bukin.dima@gmail.com
%
% Caveats:
% many :)

$1 = "golang";

!if (keymap_p ($1)) make_keymap ($1);

definekey ("golang_insert_char_indent('}')", "}", $1);
definekey ("golang_insert_char_indent(':')", ":", $1);
definekey ("golang_insert_char_indent(')')", ")", $1);

private define golang_line_starts_with_ket()
{
bol_skip_white();
if (looking_at_char('}') ||
looking_at_char(')'))
return 1;
return 0;
}

private define golang_line_starts_case()
{
bol_skip_white();
push_mark();
skip_chars("a-z");
return is_list_element("case,default", bufsubstr(), ',') > 0;
}

% TODO: This needs improvement to prevent special cases.
% such as: a := " { // "
private define golang_line_ends_with_bra()
{
eol();
if (bfind_char('{')) {
go_right(1);
skip_white();
if (eolp() or looking_at("//"))
return 1;
}
eol();
if (bfind_char('(')) {
go_right(1);
skip_white();
if (eolp() or looking_at("//"))
return 1;
}
return 0;
}

private define golang_indent_calculate()
{
variable col = 0;
variable endblock = 0;

EXIT_BLOCK {
pop_spot ();
return col;
}

if (golang_line_starts_with_ket() ||
golang_line_starts_case())
endblock = 1;

% go to previous non blank line
push_spot_bol ();
!if (re_bsearch ("[^ \t\n]"))
return;
bol_skip_white();

col = what_column() - 1;

if (golang_line_ends_with_bra() ||
golang_line_starts_case())
col += TAB;
if (endblock)
col -= TAB;
}

private define golang_whitespace(cnt)
{
loop (cnt / TAB) insert_char('\t');
}

% Indent the current line
define golang_indent_line()
{
variable col;
col = golang_indent_calculate();
bol_trim ();
golang_whitespace( col );
}

% Insert a newline and indent the newly created line.
define golang_newline_and_indent()
{
newline();
golang_indent_line();
}

% Insert a char and possibly indent the current line.
% Keep the position of the cursor just after the char.
define golang_insert_char_indent(char)
{
variable i;
insert_char(char);
i = what_column();
bol_skip_white();
i = i - what_column();
golang_indent_line();
bol_skip_white();
goto_column(i + what_column() - 1);
del();
call("self_insert_cmd");
}

create_syntax_table ($1);
define_syntax ("//", "", '%', $1); % comments
define_syntax ("([{", ")]}", '(', $1); % delimiters
define_syntax ('"', '"', $1); % quoted strings
define_syntax ('`', '"', $1); % quoted strings
define_syntax ('\'', '\'', $1); % quoted characters
define_syntax ('\\', '\\', $1); % escape
define_syntax ("0-9a-zA-Z_", 'w', $1); % words
define_syntax ("-+0-9a-fA-FjJlLxX.", '0', $1); % Numbers
define_syntax (",;.:", ',', $1); % punctuation
define_syntax ("%-+/&*=<>|!~^", '+', $1); % operators
set_syntax_flags ($1, 0); % keywords ARE case-sensitive

() = define_keywords ($1, "ifgo", 2); % all keywords of length 2
() = define_keywords ($1, "formapvar", 3); % of length 3 ....
() = define_keywords ($1, "casechanelsefuncgototype", 4);
() = define_keywords ($1, "breakconstdeferrange", 5);
() = define_keywords ($1, "importreturnselectstructswitch", 6);
() = define_keywords ($1, "defaultpackage", 7);
() = define_keywords ($1, "continue", 8);
() = define_keywords ($1, "interface", 9);
() = define_keywords ($1, "fallthrough", 11);

% No dfa yet

%!%+
%\function{golang_mode}
%\synopsis{golang_mode}
%\usage{golang_mode ()}
%\description
% An attempt to create a golang mode.
%
% Hooks: \var{golang_mode_hook}
%!%-
define golang_mode ()
{
variable golang = "golang";

TAB = TAB_DEFAULT;
if (TAB == 0) {
TAB = 4;
}

set_mode (golang, 0x4); % flag value of 4 is generic language mode
use_keymap(golang);
set_buffer_hook ("indent_hook", "golang_indent_line");
set_buffer_hook ("newline_indent_hook", "golang_newline_and_indent");
use_syntax_table (golang);
run_mode_hooks ("golang_mode_hook");
}


JED – Long delay at launch issue

Since the mailing list archive isn’t much in the way of searchable or at least doesn’t seem to be well indexed by search engines I will be keeping a series of posts on my blog with some of the “newer” and more interesting Jed issues as well as various configuration stuff I’ve found useful. Most of you have probably already noticed other posts covering this text editor. When one is working in a terminal it is one of the better ones. I put “newer” in quotes because many times they are old issues which someone just stumbled into and most of the gray cells containing knowledge of the solution sacrificed themselves to Chardonnay or some other enjoyable form of alcohol.

Let’s get all of the offensive text editor comments out of the way up front shall we?

VI is from a time when programmers lived in caves and ate their young. So are all of the derivatives of it.

If Emacs had an editor it would be a great operating system.

Nano is fine for a quick batch file edit but its WordStar type interface make it a bit tough for actual terminal level coding, especially if you need to do a lot.

vi screenshot

jed screenshot

nano screenshot

The above images are the same main.cpp file opened with each of the 3 editors on the same machine inside of Konsole terminal. No, I didn’t tweak any configuration for colors. It is what it is.

Jed runs on a great many operating systems so we get to find out which vendors actually do things right and which do a really poor job. Apple does a really poor job. A few Linux distros had this problem in the past because the script kiddies configuring those builds didn’t now how to correctly configure an environment.

This particular configuration error is annoying for a great many programs, but Jed seems to get it reported more than others. I understand why. It is incredibly annoying to type:

jed main.cpp

then wait 5 to 35+ seconds for the screen to come up. The problem is that your OS Vendor/supplier didn’t configure localhost properly. Some Apple users find the following executed in a terminal is a great fix:

scutil --set HostName $(scutil --get LocalHostName)

Some users prefer editing /etc/hosts adding the following entries:

127.0.0.1 localhost

::1 ip6-localhost ip6-loopback

You only need the second if you have an IP6 capable machine.

Some machines see this problem only when they have an unplugged network cable, other, poorly configured systems see it all of the time. All in all JED is trying to validate the machine hostname and cannot so you end up waiting for a network timeout.