-->

Saturday, March 9, 2013

insert date of the day in emacs


Insert  date of the day using a C-p as shortcut in emacs:

(global-set-key "\C-p" 'insert-date)                                                                                                                                                                          
(defun insert-date (prefix)"Insert the current date. With prefix-argument, use ISO format. With two prefix arguments, write out the day and month name."                                                      
   (interactive "P")                                                                                                                                                                                          
   (let ((format (cond                                                                                                                                                                                        
                  ((not prefix) "W%W-%Y%m%d-%A")                                                                                                                                                              
                  ((equal prefix '(4)) "W%W - %d/%m/%Y")                                                                                                                                                      
                  ((equal prefix '(16)) "%A, %d. %B %Y")))                                                                                                                                                    
         (system-time-locale "de_DE"))                                                                                                                                                                        
     (insert (format-time-string format))))      


you can configure pretty much everything by modifying the string in red every

check this if you want to know more

No comments:

Post a Comment