I've been upgrading my Emacs/Elisp more than normal lately, and it's quite interesting. Despite the syntax being the same as Clojure, Elisp feels much more enlightening to use. As a comparison, Clojure makes it incredibly pleasurable to apply transformations on data, and what feels like it would take thousands of lines of Java can be done in dozens of lines of Clojure, but I still know how to do those things in non-Clojure. On the other hand, with Elisp, the feeling that when something bothers me, I can just change it easily, which is not something I felt when using Sublime Text, Eclipse, Intellij, or Vim.

On that note, I've started playing with emacs-w3m and the behaviour bothered me a bit. I like having links in an org-mode file and opening a few in a row, but the default browse-url took over my window, but all I had to do was write a bit of Elisp, and the problem is solved for good:

  (defun my/w3m-browse-url-dwim (url &optional new-session)
    "Open url in existing visible w3m buffer, or make one if none exists"
    (interactive (browse-url-interactive-arg "Emacs-w3m URL: "))
    (if (derived-mode-p 'w3m-mode)
        ;; Currently in a w3m buffer - go to url in new session
        (w3m-goto-url-new-session url)
      ;; Not in w3m - Find the first visible w3m buffer
      (let ((this-buffer (current-buffer))
            (list (buffer-list)))
        (while list
          (with-current-buffer (car list)
            (if (and (derived-mode-p 'w3m-mode)
                     (get-buffer-window))
                ;; open url in that buffer
                (with-selected-window (get-buffer-window)
                  (setq list nil)
                  (w3m-goto-url-new-session url))
              (progn (setq list (cdr list))
                     ;; if there is no w3m buffer, make a new one
                     (when (not list)
                       (w3m-browse-url url new-session)))))))))

I initially modelled it very heavily after Sacha Chua's post on w3m, but as I was writing this, I realized that I now know a better way of doing it:

  (defun my/w3m-browse-url-dwim (url &optional new-session)
    "Open url in existing visible w3m buffer, or make one if none exists"
    (interactive (browse-url-interactive-arg "Emacs-w3m URL: "))
    (if (derived-mode-p 'w3m-mode)
        ;; Currently in a w3m buffer - go to url in new session
        (w3m-goto-url-new-session url)
      ;; Not in w3m - Find the first visible w3m buffer
      (let ((buffer (cl-find-if (lambda (buffer)
                                   (and
                                    ;; buffer is in w3m mode
                                    (with-current-buffer buffer
                                      (derived-mode-p 'w3m-mode))
                                    ;; buffer is visible
                                    (get-buffer-window buffer)))
                                (buffer-list))))
        (if buffer
            ;; open url in that buffer
            (with-selected-window (get-buffer-window buffer)
              (w3m-goto-url-new-session url))
          ;; if there is no w3m buffer, make a new one
          (w3m-browse-url url new-session)))))

Not only does Elisp feel great, I feel like it's just the beginning for me.