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 18:23:07 +0200 (CEST)

I am encountering tho problem you are mentioning.  "cs" stays at nil.





   (let (cs)
     (cond 

       ((eq major-mode 'emacs-lisp-mode) ";;")
       ((eq major-mode 'texinfo-mode)    "@c")
       ((eq major-mode 'f90-mode)        "!!")
       ((eq major-mode 'fortran-mode)    "cc"))

     (let* ( (m 62) (n 69)
         (lena (- m (current-column)))
         (lenb (- n (current-column))) )

       (message "cs: %s" cs)
       
       (pcase k
     (0
          ;; makes s to be line with repeating ";" lena times
      (setq-local s (concat cs " " (make-string lena ?\;)))
      (my-insert s k)
          (setq-local k 1))











From: Stefan Möding <s.moeding@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Using comment characters for specific major modes
Date: 06/06/2021 18:02:20 Europe/Paris

martin-kemp@brusseler.com writes:

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

The value returned by the cond form is the value of the selected cond
clause. You can use the literals without calling any additional code:

(let ((cm (cond ((eq major-mode 'emacs-lisp-mode) ";;")
((eq major-mode 'texinfo-mode) "@c")
...

Remember that `cm' will be nil if nothing was matched.

-- 
Stefan




reply via email to

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