From ec3f02ce0ff4e9fa24d924738a86a62a373394a9 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 2 Feb 2017 17:31:04 +0100 Subject: emacs: fixed some issues on ERC and added WoMan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- emacs/custom.el | 3 +- emacs/init.html | 141 ++++++++++++++++++++++++++++++++++++-------------------- emacs/init.org | 101 +++++++++++++++++++++++++--------------- 3 files changed, 158 insertions(+), 87 deletions(-) diff --git a/emacs/custom.el b/emacs/custom.el index 432ab18..af4867b 100644 --- a/emacs/custom.el +++ b/emacs/custom.el @@ -7,8 +7,9 @@ ["#1c1c1c" "#d78787" "#b9dc92" "#ffffaf" "#87afd7" "#875f87" "#dfafdf" "#d0d0d0"]) '(custom-safe-themes (quote - ("8e6f5b61626315a98a6b38acfe966800777bf6a1841aa2b812b471772cc17114" "5869e98ef7446c9e2283e5788c0f6e2790676bdb52e9e1e112bb74e2415733c4" "5a3f33eefbcf2a3098bafd22d7ad44358e66c3e844797e7bf9ef552a08dfeb6f" default))) + ("7e69e41a60afea0bea1e5f7a89416466db331ec45cbafe47ebec694411c997b8" "3762f105d8ea307cec0ee7cc36dcbce1ab0009ca1ae448fd07e8e8e65647431f" "75080b8936556e23444bd76fcfc042e484a50a403ccb7f36fd190c21f7bf8941" "e2669e7d32201debd97395277167b6a1d93606b9445ebce01b9f878eb980e200" "92eb47cefb2f03abaaaa52c60a0b89845361577c2201d3399d19b944828505f4" "62c1fac02f61eaad07bf39fd461f5c78ee3424ba87a1f5fe91b1bea25475f327" "62f08bc59e1ac24e6df5b5b01fea2da24f2fec201b285ccda9991b7052a3a46a" "ce1c38b72f45eed22f3dfaf7f3f0df4b0b6ed975cc5d2012fb1aad13e8055840" "e8b0224a3bd5da096120bf19c976a29cfe67af41bfe73171348bfe99ee0da62d" "ad1c0d9498ad9344082d47e3a1bb6b75f0d004e0ae8361613b0c9963b23fbb4d" "8e6f5b61626315a98a6b38acfe966800777bf6a1841aa2b812b471772cc17114" "5869e98ef7446c9e2283e5788c0f6e2790676bdb52e9e1e112bb74e2415733c4" "5a3f33eefbcf2a3098bafd22d7ad44358e66c3e844797e7bf9ef552a08dfeb6f" default))) '(delete-selection-mode nil) + '(electric-indent-mode t) '(magit-commit-arguments (quote ("--all" "--verbose" "--signoff"))) '(magit-log-arguments (quote ("--graph" "--color" "--decorate" "-n256"))) '(markdown-command "/usr/bin/markdown-calibre") diff --git a/emacs/init.html b/emacs/init.html index 10cfed1..ee04228 100644 --- a/emacs/init.html +++ b/emacs/init.html @@ -4,7 +4,7 @@ mssola's GNU Emacs configuration - + @@ -183,9 +183,10 @@ for the JavaScript code in this tag.
  • IRC
  • Languages
  • -
  • Misc
  • -
  • Credits
  • -
  • License
  • +
  • WoMan
  • +
  • Misc
  • +
  • Credits
  • +
  • License
  • @@ -821,22 +822,21 @@ buffers.
    -
    (defun erc-helm-buffer-list ()
    +
    (defun mssola-erc-helm-buffer-list ()
       "Returns a list with the ERC buffers."
       (mapcar 'buffer-name (erc-buffer-list)))
     
    -(setq helm-source-erc-channel-list
    +(setq mssola-helm-source-erc-channel-list
           '((name . "ERC Channels")
    -        (candidates . erc-helm-buffer-list)
    -        (action . helm-switch-to-buffer)))
    +        (candidates . mssola-erc-helm-buffer-list)
    +        (action . switch-to-buffer)))
     
    -(defun erc-helm-switch-buffer ()
    -  "Use helm to select an active ERC buffer.  Replaces erc-iswitchb, which
    -doesn't work for me."
    +(defun mssola-erc-helm-switch-buffer ()
    +  "Use helm to select an active ERC buffer."
     
       (interactive)
     
    -  (helm :sources '(helm-source-erc-channel-list)
    +  (helm :sources '(mssola-helm-source-erc-channel-list)
             :buffer "*helm-erc-channels*"))
     
     (defun mssola-find-file ()
    @@ -845,7 +845,7 @@ buffers.
       (interactive)
     
       (if (string= major-mode "erc-mode")
    -      (erc-helm-switch-buffer)
    +      (mssola-erc-helm-switch-buffer)
         (condition-case nil
             (helm-projectile-find-file)
           (error
    @@ -2041,71 +2041,67 @@ I'm giving ERC a chance. First of all, I'm setting up basic stuff.
     
       (erc-track-mode t)
     
    -  (setq erc-hide-list '("PART" "QUIT" "JOIN")
    +  (setq erc-hide-list '("PART")
             erc-prompt (lambda () (concat (buffer-name) ">"))
             erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE")
             erc-server-coding-system '(utf-8 . utf-8)
             erc-kill-buffer-on-part t
             erc-kill-queries-on-quit t
             erc-kill-server-buffer-on-quit t
    -        erc-fill-column 130
    +        erc-fill-column 100
    +        erc-fill-prefix ""
             erc-log-channels t
             erc-log-write-after-insert t
             erc-log-insert-log-on-open nil
    -        erc-timestamp-format "%s "
    -        erc-hide-timestamps t
    +        erc-log-channels-directory "~/.emacs.d/erc/"
    +        erc-timestamp-format "[%H:%M] "
             erc-insert-timestamp-function 'erc-insert-timestamp-left
             erc-insert-away-timestamp-function 'erc-insert-timestamp-left
    +        erc-hide-timestamps nil
             erc-whowas-on-nosuchnick t
             erc-public-away-p nil
             erc-echo-notice-always-hook '(erc-echo-notice-in-minibuffer)
             erc-auto-set-away nil
             erc-autoaway-message "%i seconds out..."
             erc-away-nickname "msabate"
    -        erc-log-channels-directory "~/.emacs.d/erc/"
             erc-enable-logging t
             erc-query-on-unjoined-chan-privmsg t)
     
       (setq erc-autojoin-channels-alist
    -        '(("*.freenode.net" "#gnu" "#emacs")
    -          ("*.suse.de" "#suse" "#docker")))
    +        '(("irc.freenode.net" "#gnu" "#emacs")
    +          ("irc.suse.de" "#suse" "#docker")))
     

    -I want to have a desktop notification whenever someone mentions my name. +Use the erc-hl-nicks package, so highlight support for nicknames is better.

    -
    (require 'notifications)
    -
    -(defun erc-global-notify (match-type nick message)
    -  "Notify when a message is recieved."
    -
    -  (when (eq match-type 'current-nick)
    -    (notifications-notify
    -     :title nick
    -     :body message
    -     :app-icon (concat
    -                "/usr/share/emacs/"
    -                (format "%s.%s" emacs-major-version emacs-minor-version)
    -                "/etc/images/icons/hicolor/24x24/apps/emacs.png")
    -     :urgency 'low)))
    -
    -(when (boundp 'dbus-compiled-version)
    -  (add-hook 'erc-text-matched-hook 'erc-global-notify))
    +
    (use-package erc-hl-nicks
    +  :ensure t
    +  :init
    +  (with-eval-after-load 'erc
    +    (add-to-list 'erc-modules 'hl-nicks)))
     

    -Use the erc-hl-nicks package, so highlight support for nicknames is better. +I want to have a desktop notification whenever someone mentions my name. For +this, I'm using the erc-notifications package which is built in ERC since +GNU Emacs 24.3.

    -
    (use-package erc-hl-nicks
    -  :ensure t)
    +
    (with-eval-after-load 'erc
    +  (setq erc-notifications-icon
    +        (concat
    +         "/usr/share/emacs/"
    +         (format "%s.%s" emacs-major-version emacs-minor-version)
    +         "/etc/images/icons/hicolor/24x24/apps/emacs.png"))
    +  (add-to-list 'erc-modules 'notifications))
     
    @@ -2140,6 +2136,18 @@ At this point, we can safely update all the loaded ERC modules. +

    +According to the wiki, auto-fill-mode should be disabled if I'm using +erc-fill-mode. +

    + +
    + +
    (add-hook 'erc-mode-hook
    +          (lambda () (auto-fill-mode 0)))
    +
    +
    +

    And now define a function to connect to both IRC servers.

    @@ -2449,9 +2457,44 @@ criteria really).
    -

    Misc

    +

    WoMan

    +WoMan is a package that is included inside of GNU Emacs by default, and that +takes care of visualizing man pages. Let's properly setup Evil mode for this: +

    + +
    + +
    (with-eval-after-load "evil"
    +  (evil-set-initial-state 'woman-mode 'normal)
    +  (evil-define-key 'normal woman-mode-map
    +    "J" 'Man-next-section
    +    "K" 'Man-previous-section
    +    "\C-h" 'evil-window-left
    +    "\C-l" 'evil-window-right
    +    "\C-j" 'evil-window-down
    +    "\C-k" 'evil-window-up
    +    "\C-u" 'evil-scroll-up))
    +
    +
    + +

    +Finally, I want man pages to fill all the frame: +

    + +
    + +
    (setq woman-fill-frame t)
    +
    +
    +
    +
    + +
    +

    Misc

    +
    +

    Install a set of useful functions from @bbatsov. The bindings are following Emacs style instead of being more Vim-like on purpose (I don't want to put too many things into my leader and these shortcuts look sensible to me). @@ -2468,9 +2511,9 @@ too many things into my leader and these shortcuts look sensible to me).

    -
    -

    Credits

    -
    +
    +

    Credits

    +

    I've built this file by simply scavenging from other people's emacs.d/dotfiles repositories. I have taken lots of pieces from here and there, but most notably: @@ -2495,9 +2538,9 @@ repositories. I have taken lots of pieces from here and there, but most notably:

    -
    -

    License

    -
    +
    +

    License

    +
    Copyright (C) 2014-2017 Miquel Sabaté Solà <mikisabate@gmail.com>
    @@ -2521,7 +2564,7 @@ along with this program.  If not, see <
     
    diff --git a/emacs/init.org b/emacs/init.org index 10c8f52..8a9feb9 100644 --- a/emacs/init.org +++ b/emacs/init.org @@ -484,22 +484,21 @@ function. As a final touch, this binding also works for listing channels in ERC buffers. #+BEGIN_SRC elisp -(defun erc-helm-buffer-list () +(defun mssola-erc-helm-buffer-list () "Returns a list with the ERC buffers." (mapcar 'buffer-name (erc-buffer-list))) -(setq helm-source-erc-channel-list +(setq mssola-helm-source-erc-channel-list '((name . "ERC Channels") - (candidates . erc-helm-buffer-list) - (action . helm-switch-to-buffer))) + (candidates . mssola-erc-helm-buffer-list) + (action . switch-to-buffer))) -(defun erc-helm-switch-buffer () - "Use helm to select an active ERC buffer. Replaces erc-iswitchb, which -doesn't work for me." +(defun mssola-erc-helm-switch-buffer () + "Use helm to select an active ERC buffer." (interactive) - (helm :sources '(helm-source-erc-channel-list) + (helm :sources '(mssola-helm-source-erc-channel-list) :buffer "*helm-erc-channels*")) (defun mssola-find-file () @@ -508,7 +507,7 @@ doesn't work for me." (interactive) (if (string= major-mode "erc-mode") - (erc-helm-switch-buffer) + (mssola-erc-helm-switch-buffer) (condition-case nil (helm-projectile-find-file) (error @@ -1460,63 +1459,59 @@ I'm giving ERC a chance. First of all, I'm setting up basic stuff. (erc-track-mode t) - (setq erc-hide-list '("PART" "QUIT" "JOIN") + (setq erc-hide-list '("PART") erc-prompt (lambda () (concat (buffer-name) ">")) erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE") erc-server-coding-system '(utf-8 . utf-8) erc-kill-buffer-on-part t erc-kill-queries-on-quit t erc-kill-server-buffer-on-quit t - erc-fill-column 130 + erc-fill-column 100 + erc-fill-prefix "" erc-log-channels t erc-log-write-after-insert t erc-log-insert-log-on-open nil - erc-timestamp-format "%s " - erc-hide-timestamps t + erc-log-channels-directory "~/.emacs.d/erc/" + erc-timestamp-format "[%H:%M] " erc-insert-timestamp-function 'erc-insert-timestamp-left erc-insert-away-timestamp-function 'erc-insert-timestamp-left + erc-hide-timestamps nil erc-whowas-on-nosuchnick t erc-public-away-p nil erc-echo-notice-always-hook '(erc-echo-notice-in-minibuffer) erc-auto-set-away nil erc-autoaway-message "%i seconds out..." erc-away-nickname "msabate" - erc-log-channels-directory "~/.emacs.d/erc/" erc-enable-logging t erc-query-on-unjoined-chan-privmsg t) (setq erc-autojoin-channels-alist - '(("*.freenode.net" "#gnu" "#emacs") - ("*.suse.de" "#suse" "#docker"))) + '(("irc.freenode.net" "#gnu" "#emacs") + ("irc.suse.de" "#suse" "#docker"))) #+END_SRC -I want to have a desktop notification whenever someone mentions my name. +Use the =erc-hl-nicks= package, so highlight support for nicknames is better. #+BEGIN_SRC elisp - (require 'notifications) - - (defun erc-global-notify (match-type nick message) - "Notify when a message is recieved." - - (when (eq match-type 'current-nick) - (notifications-notify - :title nick - :body message - :app-icon (concat - "/usr/share/emacs/" - (format "%s.%s" emacs-major-version emacs-minor-version) - "/etc/images/icons/hicolor/24x24/apps/emacs.png") - :urgency 'low))) - - (when (boundp 'dbus-compiled-version) - (add-hook 'erc-text-matched-hook 'erc-global-notify)) +(use-package erc-hl-nicks + :ensure t + :init + (with-eval-after-load 'erc + (add-to-list 'erc-modules 'hl-nicks))) #+END_SRC -Use the =erc-hl-nicks= package, so highlight support for nicknames is better. +I want to have a desktop notification whenever someone mentions my name. For +this, I'm using the =erc-notifications= package which is built in ERC since +GNU Emacs 24.3. #+BEGIN_SRC elisp - (use-package erc-hl-nicks - :ensure t) +(with-eval-after-load 'erc + (setq erc-notifications-icon + (concat + "/usr/share/emacs/" + (format "%s.%s" emacs-major-version emacs-minor-version) + "/etc/images/icons/hicolor/24x24/apps/emacs.png")) + (add-to-list 'erc-modules 'notifications)) #+END_SRC Some extra cookies: allow ERC to display images and Youtube thumbnails. @@ -1542,6 +1537,14 @@ At this point, we can safely update all the loaded ERC modules. (lambda (x) (erc-update-modules))) #+END_SRC +According to the [[https://www.emacswiki.org/emacs/ErcFilling][wiki]], =auto-fill-mode= should be disabled if I'm using +=erc-fill-mode=. + +#+BEGIN_SRC elisp +(add-hook 'erc-mode-hook + (lambda () (auto-fill-mode 0))) +#+END_SRC + And now define a function to connect to both IRC servers. #+BEGIN_SRC elisp @@ -1793,6 +1796,30 @@ criteria really). (add-hook lang-hook 'soria-purple-identifiers)) #+END_SRC +* WoMan + +=WoMan= is a package that is included inside of GNU Emacs by default, and that +takes care of visualizing man pages. Let's properly setup Evil mode for this: + +#+BEGIN_SRC elisp +(with-eval-after-load "evil" + (evil-set-initial-state 'woman-mode 'normal) + (evil-define-key 'normal woman-mode-map + "J" 'Man-next-section + "K" 'Man-previous-section + "\C-h" 'evil-window-left + "\C-l" 'evil-window-right + "\C-j" 'evil-window-down + "\C-k" 'evil-window-up + "\C-u" 'evil-scroll-up)) +#+END_SRC + +Finally, I want man pages to fill all the frame: + +#+BEGIN_SRC elisp +(setq woman-fill-frame t) +#+END_SRC + * Misc Install a set of useful functions from [[https://github.com/bbatsov][@bbatsov]]. The bindings are following -- cgit v1.2.3