all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help! I accidentally redefined `quote'!
@ 2023-02-12 16:38 Emanuel Berg
  0 siblings, 0 replies; only message in thread
From: Emanuel Berg @ 2023-02-12 16:38 UTC (permalink / raw)
  To: help-gnu-emacs

... 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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-12 16:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-12 16:38 Help! I accidentally redefined `quote'! Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.