Fork me on GitHub
#emacs
<
2022-09-28
>
pesterhazy14:09:15

Does anyone know of a way to paste text as a comment? For example, I want to translate some Java code to Clojure. So I want to paste the java as a comment. If I just paste the Java code in, Emacs tries to reformat it. But I want it verbatim, but behind ;;

otfrom14:09:57

do you have something like aggressive-indent turned on?

otfrom14:09:10

that will be doing the formatting then. I'm not sure how to do a paste w/o that kicking in, but I suppose you could toggle the minor mode and then comment it out

otfrom14:09:15

and then toggle it back on

pesterhazy14:09:12

Just tried it, that works better, thanks!

pesterhazy14:09:43

Would still be useful to have that as a package...

Benjamin12:09:45

(defun paste-as-comment ()
  (interactive)
  (let ((beg (point-marker))
	(end (save-excursion
	       (insert " ")
	       (point-marker))))
    (yank-pop)
    (comment-region beg end)))
first version 😛

pesterhazy13:09:00

whole guacamole, it works!

pesterhazy13:09:12

thank you so much @U02CV2P4J6S!

❤️ 1
J15:09:24

Hi guys! I try to setup emacs but I don’t understand why ivy is not activated with this code:

(use-package ivy
  :bind (:map ivy-minibuffer-map
	 ("C-j" . ivy-next-line)
	 ("C-k" . ivy-previous-line))
  :config
  (ivy-mode 1))
When I remove the :bind , ivy is activated 😕

dakra16:09:34

:bind or :hook makes use-package lazy load the package. You have to add :demand t to always load.

J19:09:30

Thanks @UFAP0C8KU for your explanation

djm16:09:42

Or just changing :`config` to :init should do it.