                          (add-to-list 'electric-pair-text-pairs '(?` . ?`))
                          ;; Do not fill source code blocks inside docstring
                          (make-variable-buffer-local 'filladapt-not-token-table)
-                         (add-to-list 'filladapt-not-token-table "`")
+                         (add-to-list 'filladapt-not-token-table "\"\"\"")
                          )))
   :bind (:map julia-mode-map
-              ("C-h ." . danylo/julia-help-at-point)))
+              ("C-h ." . danylo/julia-help-at-point)
+              ("C-c f b" . danylo/docstring-insert-bold)
+              ("C-c f i" . danylo/docstring-insert-italic)
+              ("C-c f c" . danylo/docstring-insert-literal)
+              ("C-c f e" . danylo/docstring-insert-equation)))
 
 (defun danylo/ignore-triple-backticks (orig-fun &rest args)
   "Patch the Julia syntax coloring so that triple back ticks are


(add-hook 'julia-mode-hook 'danylo/julia-imenu-hooks)

;;;; Block comment

(defun danylo/julia-block-comment ()
  "Julia block comment."

    (unless (danylo/fill)
      (fill-paragraph))
    ))

(defun danylo/julia-docstring-fill-skip ()
  "Return T if this block of text should not be filled. This occurs
in the following cases:
- It is a source code block;
- It is the initial list of function call signatures at the top of the
  docstring."
  (let* ((current-line (buffer-substring
                        (line-beginning-position) (line-end-position)))
         (has-backticks (string-match-p "^\s*```" current-line))
         (indent-this-line (current-indentation))
         is-heading
         (indent-last-line
          ;; Undo narrowing by filladapt temporarily. See
          ;; https://www.gnu.org/software/emacs/manual/html_node/eintr/save_002drestriction.html#:~:text=In%20Emacs%20Lisp%2C%20you%20can,narrowing%20that%20the%20code%20caused.
          (save-restriction
            (widen)
            (save-excursion
              (forward-line -1)
              (current-indentation)
              (setq is-heading
                    (string-match-p
                     "^\s*\"\"\""
                     (buffer-substring
                      (line-beginning-position)
                      (line-end-position))))))))
    (or has-backticks
        (and is-heading
             (eq indent-this-line
                 (+ indent-last-line julia-indent-offset))))
    ))

(defun danylo/filladapt--fill-paragraph (orig-fun &rest args)
  "Patch fill-adapt according to mode."
  (cond ((derived-mode-p 'julia-mode)
         (unless (danylo/julia-docstring-fill-skip)
           (apply orig-fun args)))
        (t (apply orig-fun args))))
(advice-add 'filladapt--fill-paragraph :around
            #'danylo/filladapt--fill-paragraph)

(general-define-key
 "M-q" 'danylo/smart-fill)
