all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dupe wars
@ 2021-10-01  2:40 Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; only message in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-01  2:40 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: emacs-w3m

o/

See the below code - but I still get duplicate entries in
~/URL

A seemingly trivial task that picks up complexity in
unexpected habitats ...

Ideas?

TIA

(defun append-string-to-file (str file &optional uniq)
  (unless (and uniq
               (xref-matches-in-files (regexp-quote str) (list file)) )
    (append-to-file (format "%s\n" str) nil file) ))

(defun w3m-kill-url-dwim ()
  (interactive)
  (let*((url        (or (w3m-anchor)
                        (thing-at-point 'url)
                        w3m-current-url) )
        (title      (when (string= url w3m-current-url)
                      (w3m-current-title) ))
        (title-part (if title
                      (format " ; %s" title)
                      "") )
        (cmd        (format "echo \"%s\" | xi" url)) )
    (append-string-to-file (format "%s%s" url title-part)
                           (format "%s/URL" (getenv "HOME")) t)
    (kill-new url)
    (shell-command cmd) )
  (message "%s" (current-kill 0)) )

https://dataswamp.org/~incal/emacs-init/w3m/w3m-url.el
https://dataswamp.org/~incal/emacs-init/w3m/

-- 
underground experts united
https://dataswamp.org/~incal




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

only message in thread, other threads:[~2021-10-01  2:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-01  2:40 dupe wars Emanuel Berg via Users list for the GNU Emacs text editor

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.