Skip to content

Commit

Permalink
Enable lexical-binding
Browse files Browse the repository at this point in the history
  • Loading branch information
SqrtMinusOne committed Jul 9, 2022
1 parent aa279bf commit 008f88a
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lisp/dank-mode-backend.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode-backend.el --- Major mode for browsing Reddit
;;; dank-mode-backend.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand Down
2 changes: 1 addition & 1 deletion lisp/dank-mode-comment.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode-comment.el --- Major mode for browsing Reddit
;;; dank-mode-comment.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand Down
8 changes: 4 additions & 4 deletions lisp/dank-mode-comments.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode-comments.el --- Major mode for browsing Reddit
;;; dank-mode-comments.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand Down Expand Up @@ -426,17 +426,17 @@ If there is no next root, then navigate to the end of the comment."
(defun dank-mode-comments-browse-post-link (&optional eww)
"Open the current post link in a browser.
If EWW is non-nil, browse in eww instead of the browser."
(interactive)
(interactive "P")
(let* ((post-link (dank-mode-post-link dank-mode-comments-current-post))
(browse-url-browser-function (if eww 'eww-browse-url 'browse-url-default-browser)))
(browse-url post-link)))

(defun dank-mode-comments-browse-post-comments (&optional eww)
"Open the current comments in a browser.
If EWW is non-nil, browse in eww instead of the browser."
(interactive)
(interactive "P")
(let ((browse-url-browser-function (if eww 'eww-browse-url 'browse-url-default-browser)))
(browse-url (concat "https://old.reddit.com" dank-mode-comments-current-permalink))))
(browse-url (concat (dank-mode-utils-reddit-url) dank-mode-comments-current-permalink))))

(provide 'dank-mode-comments)
;;; dank-mode-comments.el ends here
2 changes: 1 addition & 1 deletion lisp/dank-mode-faces.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode-faces.el --- Major mode for browsing Reddit
;;; dank-mode-faces.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand Down
2 changes: 1 addition & 1 deletion lisp/dank-mode-oauth.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode-oauth.el --- Major mode for browsing Reddit
;;; dank-mode-oauth.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand Down
2 changes: 1 addition & 1 deletion lisp/dank-mode-post.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode-post.el --- Major mode for browsing Reddit
;;; dank-mode-post.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand Down
10 changes: 5 additions & 5 deletions lisp/dank-mode-posts.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode-posts.el --- Major mode for browsing Reddit
;;; dank-mode-posts.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand Down Expand Up @@ -325,18 +325,18 @@ Optional SORTING is the sort order for the comments."
(defun dank-mode-posts-browse-post-link-at-point (pos &optional eww)
"Open the post link at POS in a browser.
If EWW is non-nil, browse in eww instead of the browser."
(interactive "d")
(interactive "d\nP")
(let* ((post-link (dank-mode-post-link (dank-mode-utils-ewoc-data dank-mode-posts-current-ewoc pos)))
(browse-url-browser-function (if eww 'eww-browse-url 'browse-url-default-browser)))
(browse-url post-link)))

(defun dank-mode-posts-browse-post-comments-at-point (pos &optional eww)
"Open the post comments at POS in a browser.
If EWW is non-nil, browse in eww instead of the browser."
(interactive "d")
(let ((post-permalink (dank-mode-post-permalink (dank-mode-utils-ewoc-data dank-mode-posts-current-ewoc point)))
(interactive "d\nP")
(let ((post-permalink (dank-mode-post-permalink (dank-mode-utils-ewoc-data dank-mode-posts-current-ewoc pos)))
(browse-url-browser-function (if eww 'eww-browse-url 'browse-url-default-browser)))
(browse-url (concat "https://old.reddit.com" post-permalink))))
(browse-url (concat (dank-mode-utils-reddit-url) post-permalink))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; interaction functions ;;
Expand Down
2 changes: 1 addition & 1 deletion lisp/dank-mode-url.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode-url.el --- Major mode for browsing Reddit
;;; dank-mode-url.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand Down
13 changes: 12 additions & 1 deletion lisp/dank-mode-utils.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode-utils.el --- Major mode for browsing Reddit
;;; dank-mode-utils.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand All @@ -24,6 +24,11 @@
:type 'function
:group 'dank-mode)

(defcustom dank-mode-prefer-new-reddit nil
"Prefer new Reddit over old Reddit."
:type 'boolean
:group 'dank-mode)

(when (require 'markdown-mode nil 'noerror)
(setq dank-mode-utils-fill-paragraph-function 'markdown-fill-paragraph)
(setq dank-mode-utils-fill-forward-paragraph-function 'markdown-fill-forward-paragraph))
Expand Down Expand Up @@ -179,6 +184,12 @@ transformation."
t t)
(set-match-data saved-match-data))))

(defun dank-mode-utils-reddit-url ()
"Return the preferred Reddit URL"
(if dank-mode-prefer-new-reddit
"https://www.reddit.com"
"https://old.reddit.com"))

(provide 'dank-mode-utils)

;;; dank-mode-utils.el ends here
2 changes: 1 addition & 1 deletion lisp/dank-mode.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dank-mode.el --- Major mode for browsing Reddit
;;; dank-mode.el --- Major mode for browsing Reddit -*- lexical-binding: t -*-

;; Copyright (C) 2021 John Louis Del Rosario

Expand Down

0 comments on commit 008f88a

Please sign in to comment.