twlz0ne / separedit.el

Edit comment or string/docstring or code block inside them in separate buffer with your favorite mode
GNU General Public License v3.0
144 stars 14 forks source link

doesn't work with clojure-mode out of the box #17

Open j-cr opened 4 years ago

j-cr commented 4 years ago

Since clojure is a lisp, it uses exactly the same comment format as other lisps. Thus it would be nice if this packaged worked with clojure-mode out of the box.

a13 commented 4 years ago

A related question, why separedit doesn't use comment-region functionality instead of hard-coding every major mode possible?

twlz0ne commented 4 years ago

@j-cr Can you provide more detail or a minimal configuration to reproduce the issue?

Or you can run the following script to confirm the issue:

test-separedit-clojure-comments.el ``` emacs-lisp ;;; Usage: /path/to/emacs -nw -Q -l /path/to/test-separedit-clojure-comments.el ;;; Date: 2020-08-16_07.57.27 (toggle-debug-on-error) ;; (setq user-emacs-directory (format "~/.emacs.d/%s/" emacs-version)) ;; (setq package-user-dir (concat user-emacs-directory "elpa/")) (package-initialize) (require 'cider-mode) (require 'clojure-mode) (require 'separedit) (define-key global-map (kbd "C-c '") #'separedit) (add-hook 'after-init-hook (lambda () (switch-to-buffer "*.clj") (clojure-mode) (insert ";; comment ;; comment<|> ;; comment") (goto-char (point-min)) (when (re-search-forward "<|>" nil t) (run-with-idle-timer 0 nil #'separedit) ))) (run-hooks 'after-init-hook) ;;; test-separedit-clojure-comments.el ends here ```

@a13 I don't know how to use comment-region to remove/restore various styles of comment delimiters, for example:

/* comment
   comment */

/*
 * comment
 */

/**
 * comment
 */

//!
//! comment
//!

//
// comment
// 
j-cr commented 4 years ago

@twlz0ne I'm not sure I understand; probably I haven't expressed myself well enough, sorry for that.

separedit-comment-delimiter-alist includes: ((";+") (emacs-lisp-mode lisp-interaction-mode common-lisp racket-mode scheme-mode)), but not clojure-mode. My suggestion is to add it to this list.

a13 commented 4 years ago

I don't know how to use comment-region to remove/restore various styles of comment delimiters

You can use the default one, unless the rules are defined, reinventing a wheel is not the best strategy

As for docs - check comment-start, comment-end, comment-start-skip vars, as well as comment-region docs