# Emacs wrong indentation after \`import Base: \*\`. Here's a workaround

**URL:** <https://discourse.julialang.org/t/emacs-wrong-indentation-after-import-base-heres-a-workaround/84585>\
**Category:** Tooling\
**Created:** [July 21, 2022, 10:45am UTC](https://discourse.julialang.org/t/emacs-wrong-indentation-after-import-base-heres-a-workaround/84585 "2022-07-21T10:45:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [July 21, 2022, 10:45am UTC](https://discourse.julialang.org/t/emacs-wrong-indentation-after-import-base-heres-a-workaround/84585/1 "2022-07-21T10:45:11Z")

</div>

There is a [known issue](https://github.com/JuliaEditorSupport/julia-emacs/issues/12) with the indentation of `julia-mode` in Emacs, giving your code formatted like this

```julia
import Base: *
    a = 1

```

This is because Emacs believes the first line ends with a hanging operator `*`, so considers the second line to be the rest of the same statement. This is annoying for me since I often overload arithmetic operators. I found a quick and dirty workaround to disable indentation for any line following `export`, `import`, or `using`, by adding the following code to my Emacs init file:

```
(defun my-julia-indent-hanging (orig-fun &rest args)
       (if (julia-following-import-export-using) 0 (apply orig-fun args)))
(advice-add 'julia-indent-hanging :around #'my-julia-indent-hanging)

```

I’m using Melpa package version julia-mode-20220418.809. It works like this: `julia-mode.el` from the package has a function `julia-indent-hanging` to calculate the indent of a line. I modify the behavior of the function with an “advice” (like a function decorator in Python) which says that I’ll first run the function `julia-following-import-export-using` (also defined in `julia-mode.el`) to see if the current line follows a import/export/using statement. If so, the indentation 0 is returned, otherwise the original function `julia-indent-hanging` is run to calculate the indentation amount.

My workaround is very simplistic, but is OK for my use cases since I never break up an import/export statement into multiple lines.
