[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Help! I accidentally redefined `quote'!
From: |
Emanuel Berg |
Subject: |
Help! I accidentally redefined `quote'! |
Date: |
Sun, 12 Feb 2023 17:38:50 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
... and the whole computer, not just Emacs, became
non-responsive!
Anyway this is what I wrote, it worked when I changed the name
to "quote-ref".
Idea: one defun to get the quote from region, then another
defun - based on mode - to get the reference, so for Emacs-w3m
it'll be `w3m-current-url', one can then add other modes there
if one ever quotes from those ...
This file is also needed:
https://dataswamp.org/~incal/emacs-init/dwim.el
Automate nothingness - the fun and easy way!
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/quote-ref.el
(require 'cl-lib)
(require 'dwim)
(require 'w3m)
(defun quote-ref-src (&optional mode)
(or mode (setq mode major-mode))
(cl-case major-mode
(w3m-mode (format "<%s>" w3m-current-url)) ))
(defun quote-ref (&optional beg end)
(interactive (use-region))
(or beg (setq beg (point-min)))
(or end (setq end (point-max)))
(let*((str (buffer-substring-no-properties beg end))
(line (string-trim
(replace-regexp-in-string "\\^*\\[[[:digit:]]*\\]" ""
(replace-regexp-in-string "[ \r\n\t]+" " " str) )))
(ref (quote-ref-src))
(ref-pad (if ref
(format " %s" ref)
"") )
(final (format "\"%s\"%s" line ref-pad)) )
(kill-new final) ))
(provide 'quote-ref)
--
underground experts united
https://dataswamp.org/~incal
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Help! I accidentally redefined `quote'!,
Emanuel Berg <=