2016-01-12 03:58:57 +00:00
|
|
|
;;; funcs.el --- Asm Layer functions File for Spacemacs
|
2016-01-06 09:13:05 +00:00
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2016-01-06 09:13:05 +00:00
|
|
|
;;
|
|
|
|
;; Author: Tu, Do Hoang <tuhdo1710@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-05-28 20:22:29 +00:00
|
|
|
|
2016-01-06 09:13:05 +00:00
|
|
|
(defun asm-generic-setup ()
|
|
|
|
(setq indent-tabs-mode nil) ; use spaces to indent
|
2016-05-28 20:22:29 +00:00
|
|
|
(setq tab-stop-list (number-sequence 2 60 2))) ; 2 spaces per tab
|
|
|
|
|
|
|
|
(defun asm-electric-indent-local-mode-off ()
|
|
|
|
(electric-indent-local-mode -1))
|
2016-01-06 09:13:05 +00:00
|
|
|
|
|
|
|
;; when we press ':' character, it runs `asm-colon' command in asm-mode.
|
|
|
|
;; The command automatically removes the indentation ofcurrent line, since
|
|
|
|
;; every non-whitespace character before a colon is a label in asm and
|
|
|
|
;; label has to be at the beginning of a line. However, the problem is
|
|
|
|
;; that when deleting indentation, trailing spaces are left between the
|
|
|
|
;; colon and the original point the colon was inserted.
|
|
|
|
;;
|
|
|
|
;; These functions solve that problem. First, check whether we have any
|
2019-12-05 12:24:12 +00:00
|
|
|
;; space or tab after point. If so, don't do anything because the spaces are
|
2016-01-06 09:13:05 +00:00
|
|
|
;; there intentionally. If not, we delete all trailing spaces between
|
|
|
|
;; point and colon.
|
|
|
|
(defvar asm-colon-has-space nil)
|
|
|
|
(defun asm-colon-check-space ()
|
|
|
|
(setq asm-colon-has-space nil)
|
2016-04-20 02:59:56 +00:00
|
|
|
(when (and (not (null (char-after)))
|
|
|
|
(member (string (char-after)) '(" " "\t")))
|
2016-01-06 09:13:05 +00:00
|
|
|
(setq asm-colon-has-space t)))
|
|
|
|
(defun asm-colon-delete-spaces ()
|
|
|
|
(unless asm-colon-has-space
|
|
|
|
(call-interactively 'delete-horizontal-space)))
|
|
|
|
(advice-add 'asm-colon :before 'asm-colon-check-space)
|
|
|
|
(advice-add 'asm-colon :after 'asm-colon-delete-spaces)
|