Created
January 26, 2024 06:05
-
-
Save yoshinari-nomura/ccd458f3a123fc92f7cf7d015a98b03a to your computer and use it in GitHub Desktop.
秋月電子の URL 変更に追従するための browse-url 用 advice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 秋月電子の URL 変更に追従する browse-url | |
;; browse-url-at-point 等も browse-url を使っている | |
;; | |
;; Old: https://akizukidenshi.com/catalog/g/gI-04575/ | |
;; New: https://akizukidenshi.com/catalog/g/g104575/ | |
;; → Replace "M-" to "1" | |
;; | |
(defun adjust-akizukidenshi-url (url) | |
(if (string-match "https://akizukidenshi[.]com/catalog/g/g\\(.-\\)[0-9]+/" url) | |
(replace-match "1" nil t url 1) | |
url)) | |
(defun adjust-akizukidenshi-url-advice (orig-func &rest args) | |
(setcar args (adjust-akizukidenshi-url (car args))) | |
(apply orig-func args)) | |
(advice-add 'browse-url :around 'adjust-akizukidenshi-url-advice) | |
;; どちらも OK | |
;; (browse-url "https://akizukidenshi.com/catalog/g/gI-04575/") | |
;; (browse-url "https://akizukidenshi.com/catalog/g/g104575/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment