help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using comment characters for specific major modes


From: Jean Louis
Subject: Re: Using comment characters for specific major modes
Date: Sun, 6 Jun 2021 00:50:25 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

* martin-kemp@brusseler.com <martin-kemp@brusseler.com> [2021-06-05 23:52]:
> Am using the following expression to make a line composed of ";" of length 
> lena.
> 
> The first two semicolons ";;" are for when I use elisp code.
> 
>     (setq-local s (concat ";; " (make-string lena ?\;)))
> 
> But I want to change the starting ";;" to be the comment character
> of the major mode I am working with.
> 
> For texinfo I want "@c", and for fortran-mode I want "c", and "!!"
> for f90-mode.

Those things I would always use as a function. Possibility is
great that I misunderstand you due to short description of what
you want.

(defun my-fancy-thing ()
  (interactive)
  (let* ((initial (completing-read "Comment: " '("1 ;;" "2 !!") nil t))
         (comment (substring initial 2))
         (lena 10)
         (string (make-string lena (string-to-char (substring initial 2)))))
    (insert (concat comment " " string))))

;; ;;;;;;;;;;

!! !!!!!!!!!!



-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]