LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-21-2018, 08:22 PM   #1
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,235

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Tip: have vim handle SlackBuild .info files properly


Put the following in .vimrc:

Code:
autocmd BufEnter,BufNew *.info call CheckSlackBuildInfo()
function CheckSlackBuildInfo()
    if filereadable(expand('%:p:r'). '.SlackBuild')
        setlocal filetype=sh
    endif
endfunction
Then, if you open a file whose extension is .info and there's a corresponding SlackBuild in the same directory, vim will treat the .info file as shell script.
 
Old 04-23-2018, 02:43 PM   #2
enorbet
Senior Member
 
Registered: Jun 2003
Location: Virginia
Distribution: Slackware = Main OpSys
Posts: 4,784

Rep: Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435
Nice! TY.
 
1 members found this post helpful.
Old 04-23-2018, 03:23 PM   #3
Skaendo
Senior Member
 
Registered: Dec 2014
Location: West Texas, USA
Distribution: Slackware64-14.2
Posts: 1,445

Rep: Reputation: Disabled
It would be nice to have a sub-forum for things like this.
 
Old 04-23-2018, 05:43 PM   #4
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,235

Original Poster
Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by Skaendo View Post
It would be nice to have a sub-forum for things like this.
This one?

https://www.linuxquestions.org/quest...ss-stories-23/

I thought this tip was slackware-specific enough to belong here.
 
Old 04-23-2018, 06:33 PM   #5
Skaendo
Senior Member
 
Registered: Dec 2014
Location: West Texas, USA
Distribution: Slackware64-14.2
Posts: 1,445

Rep: Reputation: Disabled
Quote:
Originally Posted by dugan View Post
This one?

https://www.linuxquestions.org/quest...ss-stories-23/

I thought this tip was slackware-specific enough to belong here.
I was thinking more Slackware centric.

I mean, how many distros ship with vim as standard software?
And how many use .info files for their installers/packages?
(Honest questions, I don't know)

A lot of tips could be considered "Slackware specific" especially ones that get thrown around here, just because Pat (and us) do things more as the devs intend. So yea, they could be considered "Linux" success stories, but how much can be applied to another distro without modification?

Anyways, it was just a thought.
 
Old 04-24-2018, 10:48 AM   #6
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,221

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
Nice idea, here's a version for Emacs people (goes in ~/.emacs):

Code:
;; enable syntax highlighting for SlackBuild .info files
(add-to-list 'auto-mode-alist '("\\.info\\'" . check-for-slackbuild))
(defun check-for-slackbuild ()
  "Check for a SlackBuild in the default directory of the current buffer, and set the major mode accordingly."
  (if (directory-files default-directory nil "\\.SlackBuild\\'")
      ;; set unix config mode if there is also a *.SlackBuild file
      (conf-unix-mode)
    ;; otherwise just text mode
    (text-mode)))
;; also update magic-mode-alist to test for *.info files by regexp
(add-to-list
 'magic-mode-alist
 '("PRGNAM=\".*\"" . conf-unix-mode))
I added an extra bit to test for a SlackBuild .info file even if the SlackBuild itself is missing (assuming the first line is PRGNAM="some text").
 
3 members found this post helpful.
Old 04-24-2018, 11:23 AM   #7
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,235

Original Poster
Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by Skaendo View Post
It would be nice to have a sub-forum for things like this.
I suppose the LQ wiki might be a good place.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tip: 24-bit True Color Terminal + tmux + vim dugan Slackware 12 08-05-2017 07:14 PM
[SOLVED] slackware - ls, vim, even man always hiden sth and how to handle this? vencent Slackware 13 06-22-2017 08:10 AM
[SOLVED] Vim Slackbuild fails to fetch vim 8.000x sources from github on -current mats_b_tegner Slackware 4 09-15-2016 06:56 PM
Any tip to handle usb's vibinlakshman Ubuntu 17 02-19-2009 09:14 AM
Fedora 8 can't handle DVD media properly? SCerovec Fedora 4 05-12-2008 03:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration