hjertnes.blog

#

21.02.2018 01:00

Feeling much better after the surgery. The wounds after the surgery hurts. But this is a hell of a lot better than the constant head ache and fever I had before.

#

21.02.2018 01:00

America. You have a constitutional right for the right to bear arms and not one for the right to protest?

#

21.02.2018 01:00

Reading a Emacs book on my iPhone in the hospital bed. I miss my laptops…

#

21.02.2018 01:00

☕️😍🤤

#

21.02.2018 01:00

Jack Baty Daniel Goldsmith Amit Gawande I blame all of you if I move to Hugo

#

21.02.2018 01:00

[@jack]1 [@dgold]2 [@amit]3 I blame all of you, when I end up spending a lot of time moving to hugo

#

21.02.2018 01:00

[@jack]1 how do I create a regular page in Hugo?

Cool Array Method

21.02.2018 01:00

Have you ever wondered if some array includes a certain element? And you just want true or false instead of the index(like you would have gotten from indexOf). Array.prototype.includes to the rescue.

I love where JavaScript are going these days. The work on ES6 was a lot about making JavaScript as a language good enough. Since then it seems like many of the features have been about making it as nice as possible to work with.

You can also use them on strings.

Getting started with Spacemacs.

21.02.2018 01:00

This post is intended for users that are curious about or never gotten started with Spacemacs. I’m going to cover the structure of the .spacemacs file and what you need to know about .emacs.d, plus some basic navigation. And some very specific advice.

Let’s start with what Spacemacs is. Spacemacs is not a emacs fork or anything like that, but rather a special way to configure it. It makes it much easier to get started than with the default .emacs.d config. Follow the official installation instructions and just hit enter on everything Spacemacs ask you about the first time you start and then give it some time. This will give you the standard setup.

The way spacemacs works is that it takes over the .emacs.d directory by cloning their git repository into .emacs.d. This has many advantages, one of them being that it is easy to update. If you need or want to add third party code or your own code, then you should add it to .emacs.d/private. It is ignored by the spacemacs git repo. That is everything you need to know about the .emacs.d directory for now.

Then you have the .spacemacs file. This is the configuration file. Spacemacs uses something called configuration layers to bundle functionality in a special way. They can be a little bit complicated to understand and get to work properly if you want to write their own. But they are totally awesome. Because they make sure that stuff don’t crash with each other more than necessary. And you typically don’t need to do a lot of “add this here, and then you modify this thing” type installation instructions. You just enable the layer and sometimes specify some variables to it, if it requires configuration.

A layer can be everything from adding support for PHP to a WakaTime client.

You .spacemacs file have the following functions:

  • dotspacemacs/layers

  • dotspacemacs/init

  • dotspacemacs/user-init

  • dotspacemacs/user-config

The layers function contains everything related to layers or emacs packages. If you want to install a package that is not a part of layer? Then you do it there. Want to enable a layer? You do it there. The init function on the other hand contains configuration settings for Spacemacs itself. Then you have user-init and user-config. Both of them contain your customisations, but most of it will probably end up in user-config; because user-init runs before your layers have been loaded while user-config runs after.

The first thing I would do is to read through the whole .spacemacs file. It contains all the settings and comments explaining them. Then I would read through the list of layers on the Spacemacs website. But only enable what you KNOW you will need. It isn’t hard to enable more layers later. And remember to enable to osx layer if you’re on a Mac.

Change what you need an restart Emacs.

There are three window management concepts you need to understand in order to get Emacs. You have the “frame” which is what you see on the screen. The frame can be split into different windows. And each window displays a buffer. But multiple windows can show the same buffer. A buffer can be everything from logs, to user interfaces to a file.

If you use the default Spacemacs settings, you will be using keybindings that are very close to those of VIM. I assume you have a basic understanding of how the VIM modes work. Make sure you are in Normal mode, Hit space. You will now se a small area pop up at the bottom of your screen. For example space ff will let you pick a file or folder to open.

There is one thing that is very important to understand about emacs. Everything you see and use in Emacs is a Emacs Lisp function. This means that if you don’t like how X works, you can always write your own custom function. If you hit space twice, you’ll enter M-x this will let you run ANY interactive function loaded as a part of your configuration. I use M-x all the time when I don’t remember the keyboard shortcut for something.

What I recommend if you want to get started with Spacemacs is to stop using your regular text editor for a week. Your productivity will be lower for a while, but it will improve a lot really fast.

Let’s begin with some basic keyboard commands:

You will often see commands like this C-a C-m, in Spacemacs that means SPC (space) a m. And M-x that means ESC x.

  • SPC ff : select folder, select file or create new file

  • SPC w : split window horizontal

  • SPC w : split window vertical

  • SPC fed : open config

  • SPC wd :remove window

  • SPC ss : list buffers

  • SPC TAB : change to last buffer

  • SPC bn : next buffer

  • SPC bp : previous buffer

  • SPC fs : save

  • SPC bd : close buffer

  • SPC feR : reload config

  • SPC pf : search for file

It is really hard in the beginning, but give it a few days and it will loosen up. Let me know if anything is unclear or if you have any questions.

Getting started with Spacemacs.

21.02.2018 01:00

This post is intended for users that are curious about or never gotten started with Spacemacs. I’m going to cover the structure of the .spacemacs file and what you need to know about .emacs.d, plus some basic navigation. And some very specific advice.

Let’s start with what Spacemacs is. Spacemacs is not a emacs fork or anything like that, but rather a special way to configure it. It makes it much easier to get started than with the default .emacs.d config. Follow the official installation instructions and just hit enter on everything Spacemacs ask you about the first time you start and then give it some time. This will give you the standard setup.

The way spacemacs works is that it takes over the .emacs.d directory by cloning their git repository into .emacs.d. This has many advantages, one of them being that it is easy to update. If you need or want to add third party code or your own code, then you should add it to .emacs.d/private. It is ignored by the spacemacs git repo. That is everything you need to know about the .emacs.d directory for now.

Then you have the .spacemacs file. This is the configuration file. Spacemacs uses something called configuration layers to bundle functionality in a special way. They can be a little bit complicated to understand and get to work properly if you want to write their own. But they are totally awesome. Because they make sure that stuff don’t crash with each other more than necessary. And you typically don’t need to do a lot of “add this here, and then you modify this thing” type installation instructions. You just enable the layer and sometimes specify some variables to it, if it requires configuration.

A layer can be everything from adding support for PHP to a WakaTime client.

You .spacemacs file have the following functions:

  • dotspacemacs/layers

  • dotspacemacs/init

  • dotspacemacs/user-init

  • dotspacemacs/user-config

The layers function contains everything related to layers or emacs packages. If you want to install a package that is not a part of layer? Then you do it there. Want to enable a layer? You do it there. The init function on the other hand contains configuration settings for Spacemacs itself. Then you have user-init and user-config. Both of them contain your customisations, but most of it will probably end up in user-config; because user-init runs before your layers have been loaded while user-config runs after.

The first thing I would do is to read through the whole .spacemacs file. It contains all the settings and comments explaining them. Then I would read through the list of layers on the Spacemacs website. But only enable what you KNOW you will need. It isn’t hard to enable more layers later. And remember to enable to osx layer if you’re on a Mac.

Change what you need an restart Emacs.

There are three window management concepts you need to understand in order to get Emacs. You have the “frame” which is what you see on the screen. The frame can be split into different windows. And each window displays a buffer. But multiple windows can show the same buffer. A buffer can be everything from logs, to user interfaces to a file.

If you use the default Spacemacs settings, you will be using keybindings that are very close to those of VIM. I assume you have a basic understanding of how the VIM modes work. Make sure you are in Normal mode, Hit space. You will now se a small area pop up at the bottom of your screen. For example space ff will let you pick a file or folder to open.

There is one thing that is very important to understand about emacs. Everything you see and use in Emacs is a Emacs Lisp function. This means that if you don’t like how X works, you can always write your own custom function. If you hit space twice, you’ll enter M-x this will let you run ANY interactive function loaded as a part of your configuration. I use M-x all the time when I don’t remember the keyboard shortcut for something.

What I recommend if you want to get started with Spacemacs is to stop using your regular text editor for a week. Your productivity will be lower for a while, but it will improve a lot really fast.

Let’s begin with some basic keyboard commands:

You will often see commands like this C-a C-m, in Spacemacs that means SPC (space) a m. And M-x that means ESC x.

  • SPC ff : select folder, select file or create new file

  • SPC w : split window horizontal

  • SPC w : split window vertical

  • SPC fed : open config

  • SPC wd :remove window

  • SPC ss : list buffers

  • SPC TAB : change to last buffer

  • SPC bn : next buffer

  • SPC bp : previous buffer

  • SPC fs : save

  • SPC bd : close buffer

  • SPC feR : reload config

  • SPC pf : search for file

It is really hard in the beginning, but give it a few days and it will loosen up. Let me know if anything is unclear or if you have any questions.