More Emacs Configuration Functions

Convert-To-Windows-Path

Convert a unix path to a dos path.


(defun convert-to-windows-path (astring)
(interactive "sAstring: ")
(with-temp-buffer
    (insert (subst-char-in-string ?/ ?\\ astring))
    (clipboard-kill-region (point-min) (point-max))))

Copy Buffer Path


(defun yt/copy-full-path-to-kill-ring ()
  "copy buffer's full path to kill ring"
  (interactive)
  (when buffer-file-name
    (kill-new (file-truename buffer-file-name))))

Save Windows Path With Spaces



(defun bounds-of-string-at-point ()
  "String at point including the string delimiters."
  (when-let ((ppss (syntax-ppss))
             (in-string (nth 3 ppss))
             (b (nth 8 ppss))
             (e-ppss (save-excursion (parse-partial-sexp (1+ b) (point-max) nil nil nil 'syntax-table)))
             (e (1+ (nth 8 e-ppss))))
    (cons b e)))

(put 'string 'bounds-of-thing-at-point #'bounds-of-string-at-point)

(defun around-ad-ffap-string-at-point (oldfun &optional mode)
  "Use the string at point for `ffap-string-at-point'
or the original function if we are not within a string."
  (let ((str-bounds (bounds-of-thing-at-point 'string)))
    (if str-bounds
        (setq ffap-string-at-point
              (buffer-substring-no-properties
               (setcar ffap-string-at-point-region (1+ (car str-bounds)))
               (setcar (cdr ffap-string-at-point-region) (1- (cdr str-bounds)))))
      (funcall oldfun mode))))

(advice-add 'ffap-string-at-point :around #'around-ad-ffap-string-at-point)

Rename This File



(defun pos-rename-current-file (newname)
  "Rename the current file to NEWNAME."
  (interactive "F")
  (let ((oldname (buffer-file-name)))
    (when oldname
      (dired-rename-file oldname newname nil))))


Popup enables pop ups used by company and other packages. Sets also a few fallback default colors.



(use-package popup
:config
(set-face-attribute 'popup-scroll-bar-foreground-face nil :background "#464f60" :inherit nil)
(set-face-attribute 'popup-scroll-bar-background-face nil :background "#263146" :inherit nil )
(set-face-attribute 'popup-menu-selection-face nil :inherit nil :background "#464f60" :foreground "#ffffff" )
(set-face-attribute 'popup-face nil :inherit nil :background "#263146" :foreground "#ffffff" )
; add some shotcuts in popup menu mode
(define-key popup-menu-keymap (kbd "C-i") 'popup-select)
(define-key popup-menu-keymap (kbd "C-n") 'popup-next)
(define-key popup-menu-keymap (kbd "C-p") 'popup-previous)
);end popup

Tooltip Configuration

Tooltip pops up on mouse over, but it is helpful even if you don’t use the mouse.

When Tooltip mode is off, Emacs displays help text in the echo area, instead of in a pop-up window.




(set-face-attribute 'tooltip nil :inherit nil :background "gray96")
(tooltip-mode 1)


Pos-tip Configuration

Pos-tip allows tooltip to be located at various places in the buffer, and provides some faces.





(use-package pos-tip
:config
(setq pos-tip-foreground-color "#FFC300")
(setq pos-tip-background-color "#2471A3")
(setq pos-tip-background-color "#2471A3")
(setq pos-tip-foreground-color "#FFC300")
;(pos-tip-w32-max-width-height)
;(pos-tip-w32-max-width-height t)
)