emacs.d

My Emacs configuration
git clone https://git.jamzattack.xyz/emacs.d
Log | Files | Refs | LICENSE

reddit-browse.el (1848B)


      1 ;;; reddit-browse.el --- Minimal functions to browse emacs in eww  -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2020  Jamie Beardslee
      4 
      5 ;; Author: Jamie Beardslee <jdb@jamzattack.xyz>
      6 ;; Keywords: net
      7 
      8 ;; This program is free software; you can redistribute it and/or modify
      9 ;; it under the terms of the GNU General Public License as published by
     10 ;; the Free Software Foundation, either version 3 of the License, or
     11 ;; (at your option) any later version.
     12 
     13 ;; This program is distributed in the hope that it will be useful,
     14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 ;; GNU General Public License for more details.
     17 
     18 ;; You should have received a copy of the GNU General Public License
     19 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
     20 
     21 ;;; Commentary:
     22 ;;
     23 ;; Here is an example use-package declaration for this package.
     24 ;;
     25 ;; (use-package reddit-browse
     26 ;;   :custom (reddit-subreddit-list '("emacs" "lisp" "lispmemes"
     27 ;; 				      "vxjunkies" "linux" "nethack"
     28 ;; 				      "cello" "throwers"))
     29 ;;   :bind ("C-z r" . reddit-goto-subreddit))
     30 
     31 ;;; Code:
     32 
     33 (defvar reddit-url-format-string "https://old.reddit.com/%s/.mobile?keep_extension=True"
     34   "The format string used for going to a subreddit. Stick with
     35 the default if you use eww, otherwise change it to your liking.")
     36 
     37 (defvar reddit-subreddit-list
     38   '("emacs" "lisp" "news" "linux" "gnu"))
     39 
     40 (defun reddit-choose-subreddit-interactively ()
     41   (completing-read "Goto subreddit: " reddit-subreddit-list))
     42 
     43 (defun reddit-goto-subreddit (subreddit)
     44   (interactive (list (reddit-choose-subreddit-interactively)))
     45   (let ((subreddit-with-r (concat "r/" subreddit)))
     46     (browse-url (format reddit-url-format-string subreddit-with-r))))
     47 
     48 (provide 'reddit-browse)
     49 ;;; reddit-browse.el ends here