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

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

Using comment characters for specific major modes


From: martin-kemp
Subject: Using comment characters for specific major modes
Date: Sun, 6 Jun 2021 11:14:26 +0200 (CEST)

You have been most helpful.  Others have given me other ways but have found 
them too complicated 

for me.  Forget using comment type functions, I will just set the variable "cm" 
directly.



I am almost there.  I have now done



   (let ((cm (cond ((eq major-mode 'emacs-lisp-mode) (do something))
           ((eq major-mode 'texinfo-mode)    (do something))
           ((eq major-mode 'f90-mode)        (do something))
           ((eq major-mode 'fortran-mode)    (do something))



What I need is to set "cm" to ";;" for 'emacs-lisp-mode, "@c" for texinfo-mode 
etc.



Have difficulty setting "cm" though.





From: Jean Louis <bugs@gnu.support>
To: martin-kemp@brusseler.com
Subject: Re: Using comment characters for specific major modes
Date: 06/06/2021 02:43:58 Europe/Paris
Cc: help-gnu-emacs@gnu.org

* martin-kemp@brusseler.com <martin-kemp@brusseler.com> [2021-06-06 03:40]:
> For emacs-lisp-mode I would like "s" to be
> 
> (setq-local s (concat ";; " (make-string lena ?\;)))


(defun my-whatever ()
(interactive)
(let ((s (cond ((eq major-mode 'adoc-mode) (do something))
((eq major-mode 'markdown-mode) (do something))
(t s))))
(insert s)))

You may use `cond' function to test the variable `major-mode' and
accordingly return the value for `s' which you then insert in the
buffer.


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